Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# CA1017与VS2010 StyleCop相关的ComVisible错误_C#_.net_Visual Studio 2010_Stylecop_Comvisible - Fatal编程技术网

C# CA1017与VS2010 StyleCop相关的ComVisible错误

C# CA1017与VS2010 StyleCop相关的ComVisible错误,c#,.net,visual-studio-2010,stylecop,comvisible,C#,.net,Visual Studio 2010,Stylecop,Comvisible,我有CA1017错误消息,StyleCop说我需要将其设置为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

我有CA1017错误消息,StyleCop说我需要将其设置为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).
然后,我将代码
[assembly:ComVisible(false)]
放在最上面的名称空间之前。但是,我仍然收到了相同的错误和其他错误消息

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也不认识这个名字

这有什么问题?

中定义了

因此,您需要:

  • 使用名称空间完全限定属性的名称:

    [assembly: System.Runtime.InteropServices.ComVisible(false)]
    
  • using
    指令添加到源文件顶部,以导入该文件的命名空间:

    using System.Runtime.InteropServices;
    
  • 将来,您应该能够让VisualStudio警告您这些事情。当您看到一条表示编译器错误的曲线时,请查找附近的下拉按钮或按Ctrl+。应出现一个菜单,指示问题的可能解决方案。在这种情况下,它会建议您选择上面列出的选项1或2,只需单击一下,您就可以执行所有必要的操作

    (上述令人惊叹的动画图像是从中拍摄的。)

    中定义了

    因此,您需要:

  • 使用名称空间完全限定属性的名称:

    [assembly: System.Runtime.InteropServices.ComVisible(false)]
    
  • using
    指令添加到源文件顶部,以导入该文件的命名空间:

    using System.Runtime.InteropServices;
    
  • 将来,您应该能够让VisualStudio警告您这些事情。当您看到一条表示编译器错误的曲线时,请查找附近的下拉按钮或按Ctrl+。应出现一个菜单,指示问题的可能解决方案。在这种情况下,它会建议您选择上面列出的选项1或2,只需单击一下,您就可以执行所有必要的操作

    (上面这张令人惊叹的动画图像是从中摘取的。)