关于CLSCompliant

本文探讨了在C#开发中使用CLSCompliant属性的意义,特别是它如何帮助DLL在不同语言间进行调用,如C#与VB.NET。通过引用相关资源和MSDN文档,解释了此属性的基本概念及其在实际开发中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在做code analysis时,遇到了这个提示

  Warning 1 CA1014 : Microsoft.Design : Mark 'Demo.exe' with CLSCompliant(true) because it exposes externally visible types. 

不明白 CLSCompliant 为何物,搜索,找到:

 CLSCompliant(true) 简单的说,是为了让C#编写的dll可以供VB.net 调用,因为两个语言毕竟有不同的地方,需要声明一下是否可以调用。

这个仁兄的解释很好:

http://www.cnblogs.com/mywebname/articles/598460.html

另外,MSDN:

 

用 CLSCompliant 标记程序集

http://msdn.microsoft.com/zh-cn/library/ms182156(v=VS.80).aspx#Y260

CLSCompliantAttribute 类

http://msdn.microsoft.com/zh-cn/library/system.clscompliantattribute.aspx

 

笔记一下,备忘。

解释每一行代码using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Diagnostics.CodeAnalysis; [assembly: AssemblyTitle("DockPanel Suite for .Net")] [assembly: AssemblyDescription(".Net Docking Library for Windows Forms")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Weifen Luo")] [assembly: AssemblyProduct("DockPanel Suite")] [assembly: AssemblyCopyright("Copyright © Weifen Luo and other contributors 2007-2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: CLSCompliant(true)] [assembly: SuppressIldasm()] [assembly: ComVisible(false)] [assembly: Guid("9d690ef9-ce19-4c69-874c-e24d8eb36aff")] [assembly: AssemblyVersion("2.9.0.0")] [assembly: AssemblyFileVersion("2.9.0.0")] [module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "namespace", Target = "WeifenLuo.WinFormsUI.Docking", MessageId = "Weifen")] [module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "namespace", Target = "WeifenLuo.WinFormsUI.Docking", MessageId = "Luo")] [module: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope = "resource", Target = "WeifenLuo.WinFormsUI.Docking.Strings.resources", MessageId = "Weifen")] [module: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope = "resource", Target = "WeifenLuo.WinFormsUI.Docking.Strings.resources", MessageId = "Luo")] [module: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope = "resource", Target = "WeifenLuo.WinFormsUI.Docking.Strings.resources", MessageId = "Dockable")]
最新发布
08-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值