什么时候可以打破CLS合规性?

编程入门 行业动态 更新时间:2024-10-27 00:29:20
本文介绍了什么时候可以打破CLS合规性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道存在哪些可能使符合通用语言规范.即使不打算从其他语言访问,我也认为 CLSCompliantAttribute 是很好的最佳实践.

I was wondering which edge cases exist that could make Common Language Specification compliance acceptable. Even when not intending to be accessed from other languages, I think that the tenets asserted by the CLSCompliantAttribute are good best practices.

您是否遇到过/知道 YAGNI 胜过最佳做法的情况?

Do you have encountered / know of cases where YAGNI outweighs the best practices?

推荐答案

"[原文]符合CLS有什么用?"

"[sic] What use is there for being CLS compliant?"

中级信任, ClickOnce ,从共享的网络驱动器运行,在域设置中配置来宾配置文件等.在许多安全情况下,您的如果违反CLS法规,则代码将无法运行.

Medium trust, ClickOnce, running from a shared network drive, guest profiles in a domain setting, etc. There are lots of security situations where your code cannot run if you break the CLS Compliance.

我亲自看到很多情况,用户试图从共享的网络驱动器上运行他们的应用程序,但由于本地管理员在安全性配置文件中杀死了不符合CLS的应用程序而无法这样做.

I have personally seen a lot of situations where users are trying to run their application from a shared network drive and can't because the local admin has killed non-CLS compliant applications in the security profile.

通常,无论如何,通常都有解决此问题的方法.对于上面的评论,我会采取相反的方法,为什么要破坏它呢?您正在编写托管代码,为什么要故意限制应用程序?

In general, there are usually ways to work around the issue anyway. I would take the opposite approach to the comments above, why break it? You are writing managed code, why would you want to limit your application on purpose?

我要说的是,如果要构建API程序集或组件,则应始终遵循它们.尝试从中等信任度运行时,太多的第三方组件会采取简单的方法,只是将它们标记为已损坏.在某些情况下,这是它们无法运行的唯一原因.如果他们花了更多时间来遵守指南,则用户将不会受到如何使用其组件的限制.

I would say that if you are building an API assembly or component, you should always adhere to them. Too many third-party components take the easy way out and just flag them as broken when attempting to run from medium trust. In some cases, this is the only reason they can't run. If they had taken a little more time to adhere to the guidelines, users would not be limited as to how they can use their component.

更多推荐

什么时候可以打破CLS合规性?

本文发布于:2023-08-01 16:46:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1269960.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:什么时候   CLS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!