C++/CLI: CA2123: Requires SecurityCriticalAttribute?

风格不统一 提交于 2019-12-22 05:29:21

问题


I am a little lost on erros like that:

Warning 7 CA2123 : Microsoft.Security : Add the following security attribute to 'RithmicConnector::Connect(String^)' in order to match a LinkDemand on base method 'IConnector::Connect(String^)': 'SecurityCriticalAttribute'. c:\work\nettecture\tradex\source\tradex.connectivity.rithmic\rithmicconnector.cpp 52 Tradex.Connectivity.Rithmic

Where do I add the SecurityCriticalAttribute?

I tried on the header file - but the error does not disappear. I have one of those pretty much on every exposed method of a (managed C++) interface DLL.

And I want CA to run through.

How do I fix those?

Regards


回答1:


You'll have to do two things:

  1. Add [assembly: SecurityCritical] to the assembly.
  2. Add [SecurityCritical] attribute to the specific methods containing critical code(or whatever else you wish to decorate).

Here's a blog entry that might be helpful Using Transparency in CLR



来源:https://stackoverflow.com/questions/2670291/c-cli-ca2123-requires-securitycriticalattribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!