.NET 中不符合 CLS 的代码会产生什么后果?
对于不久前从 VB6 移植的应用程序,我有一些关于 CLS 合规性的烦人的编译器警告,其中包括:
Name '_AnIdentifier' is not CLS-Compliant.
Type of parameter 'myType' is not CLS-Compliant.
尽管如此,我的应用程序似乎在 COM 和托管客户端上表现得很好。 我看过几篇文章,描述了如何使代码符合 CLS,我可能会继续这样做,以摆脱烦人的警告,但我很好奇不符合 CLS 的代码在实际中的缺点是什么条款? 我还没有发现这种强加的限制是什么?
I have a couple of nagging compiler warnings for an app that I ported from VB6 a while back regarding CLS-Compliance including:
Name '_AnIdentifier' is not CLS-Compliant.
Type of parameter 'myType' is not CLS-Compliant.
Despite this, my app seems to perform just fine from COM and Managed clients. I have seen several articles describing what to do to make the code CLS-Compliant and I probably will go ahead and do it anyway to get rid of the nagging warnings, but I am curious what the drawbacks of non-CLS compliant code are in practical terms? What limitations is this imposting that I haven't discovered yet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,当与某些 .NET 语言一起使用时,您的类可能无法访问(或者可能表现得很奇怪,例如大的正数被视为负数)。 我不能说它们可能是什么语言。
例如,我不认为需要一种语言来识别以下划线开头的标识符。 C# 允许这样做,因此您在那里是安全的,但对于其他语言,“_AnIdentifier”可能是隐藏的,或者具有系统生成的名称。
Basically, your class may not be accessible (or may act oddly, such as large positive numbers being treated as negative), when used with some .NET languages. I cannot say what languages they might be.
For example, I don't believe a language is required to recognize an identifer that begins with an underscore. C# allows it, so you're safe there, but for other languages, "_AnIdentifier" may be hidden, or have a system generated name.
当混淆不符合 CLS 的代码时,我遇到了混淆工具生成错误混淆代码的问题。
I've run into issues with obfuscation tools generating incorrect obfuscated code when code that isn't CLS-compliant is obfuscated.