VS2010 StyleCop与CA1017 ComVisible相关的错误

| 我的StyleCop出现CA1017错误消息,提示我需要将其设置为ComVisible false。
Error   18  CA1017 : Microsoft.Design : 
Because \'NationalInstruments.Labview.FPGA.ModelsimCommunicator.dll\' exposes externally 
visible types, mark it with ComVisible(false) at the assembly level and then mark all 
types within the assembly that should be exposed to COM clients with ComVisible(true).
然后,将代码“ 1”放在最顶层的命名空间之前。但是,我仍然遇到相同的错误以及其他错误消息。
Error   19  The type or namespace name \'ComVisible\' could not be found (are you 
missing a using directive or an assembly reference?)    


Error   20  The type or namespace name \'ComVisibleAttribute\' could not be found (are
you missing a using directive or an assembly reference?)    
似乎VS2010也无法识别此名称。 这怎么了?     
已邀请:
“ 3”是在“ 4”命名空间中定义的。 因此,您要么需要: 使用名称空间对属性名称进行完全限定:
[assembly: System.Runtime.InteropServices.ComVisible(false)]
在源文件的顶部添加一个“ 6”指令以导入该文件的名称空间:
using System.Runtime.InteropServices;
将来,您应该能够使用Visual Studio来警告您这些事情。当您看到一条弯曲的线表示编译器错误时,请查找附近的下拉按钮或按Ctrl +。应出现一个菜单,指示可能的问题解决方案。在这种情况下,建议您采用上面列出的选项1或2,并且单击一下即可为您执行所有必要的操作。 (以上惊人的动画图像是从此处撕下的。)     

要回复问题请先登录注册