可以使用“不安全”的程序集吗?方法可以从“安全”的地方运行。语境?
我想编写一些优化的“不安全”代码,但提供可在网页等沙箱中使用的辅助“安全”版本。是否可以将两者放在同一个程序集中,或者任何不安全
方法的存在是否会阻止加载程序集?
如果我可以将它们放在一个程序集中,如何检查是否可以运行快速版本?
顺便说一句,我如何运行具有更高安全性的 .exe
以便我可以自己测试它?
I'd like to write some optimized "unsafe" code, but provide a secondary "safe" version that can be used in sandboxes such as web pages. Is it possible to put both in the same assembly, or does the existence of any unsafe
methods prevent the assembly from being loaded?
If I can put them both in one assembly, how do I check if it's possible to run the fast version?
And by the way, how can I run an .exe
with raised security so I can test this myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里要小心行走。包含不安全代码的程序集被标记为“不安全”,并且需要完全信任才能加载和运行。
问题:您期望获得的性能提升是否值得冒着可能通过(不安全)代码中的漏洞将底层操作系统、机器、数据等暴露给恶意软件的风险?
我强烈建议您在引入不安全代码之前仔细分析、剖析、测量和测试您的代码 - 以及几种替代实现(如果可以的话)。我经历过一些真正需要不安全代码的场景,而当需要不安全代码时,由于代码的潜在危险性质,必须进行广泛的安全审查和分析。
您可能需要阅读以下内容:http://social.msdn.microsoft.com/Forums/en-US/clr/thread/596ab254-87ab-4f13-847d-4b15e9170475
Tread carefully here. Assemblies containing unsafe code are marked as 'unsafe' and require full-trust in order to load and run.
Question: Is the perf boost you expect to get worth the risk of possibly exposing the underlying OS, machine, data, etc. to malware via a vulnerability in your (unsafe) code?
I would STRONGLY recommend that you carefully analyze, profile, measure and test your code - and several alternative implementations if you can - before introducing unsafe code. I've experienced few scenarios where unsafe code was truly required and when it was, have had to undergo extensive security reviews and analysis due to the potentially dangerous nature of the code.
You might want to read the following: http://social.msdn.microsoft.com/Forums/en-US/clr/thread/596ab254-87ab-4f13-847d-4b15e9170475