Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.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# 在C中禁用CLS符合性检查#_C#_Cls Compliant - Fatal编程技术网

C# 在C中禁用CLS符合性检查#

C# 在C中禁用CLS符合性检查#,c#,cls-compliant,C#,Cls Compliant,我正在编写一些方法具有以下属性的代码: [CLSCompliantAttribute(false)] 当我按原样构建代码时,我如何看到正在执行合规性检查,而当我将其注释掉时,似乎没有执行合规性检查 我期待着相反的行为 添加[CLSCompliant(false)]将您添加到的成员标记为不符合 如果将该成员标记为不兼容,则编译器不会在其不兼容时发出警告。(因为您已经说过它不符合要求。) 但是,如果该成员被标记为兼容(明确或间接来自程序集级属性),但事实上它不兼容(例如,它使用uint),编译器

我正在编写一些方法具有以下属性的代码:

[CLSCompliantAttribute(false)] 
当我按原样构建代码时,我如何看到正在执行合规性检查,而当我将其注释掉时,似乎没有执行合规性检查

我期待着相反的行为

添加
[CLSCompliant(false)]
将您添加到的成员标记为不符合

如果将该成员标记为不兼容,则编译器不会在其不兼容时发出警告。(因为您已经说过它不符合要求。)


但是,如果该成员被标记为兼容(明确或间接来自程序集级属性),但事实上它不兼容(例如,它使用
uint
),编译器将警告您(因为该属性现在与该成员有关)。

例如,您可以将其添加到AssemblyInfo.cs,并对所有组件进行分组。 比如:


因此,如果我得到警告-这是否意味着我在代码的某个更高范围内有属性:[CLSCompliant(true)]?您可能在程序集级别有它。在Properties/AssemblyInfo.cs中为我们的VB.Net朋友查找
[assembly:CLSCompliant(true)]
。你能发布你的警告消息吗?
using System;
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(false)]


// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is     exposed to COM
[assembly: Guid("d29c53b6-88e4-4b33-bb86-f39b4c733542")]

// Version information for an assembly consists of the following four     values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build     Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]