问题描述
我想知道如何在.net核心中实现沙箱操作,因为.net核心中不支持appdomains。另外,由于这些东西在我的目标计算机上不可用,因此我不能使用虚拟化或文件容器。
I was wondering how I can achieve sandboxing in .net core, since appdomains are not supported in .net core for this. Also, I can't use Virtualization or docket containers because these things are not available on my target machine.
推荐答案
每个.NET核心文档,看来您的选择有点受限制。
Per .NET Core docs, looks like your options are a bit limited.
应用程序域
App Domains
为什么停产? AppDomains需要运行时
的支持,而且通常相当昂贵。尽管仍由
CoreCLR实现,但.NET Native中不提供此功能,我们不打算在此处添加
此功能。
Why was it discontinued? AppDomains require runtime support and are generally quite expensive. While still implemented by CoreCLR, it’s not available in .NET Native and we don’t plan on adding this capability there.
我应该改用什么? AppDomains用于不同的
目的。对于代码隔离,我们建议使用进程和/或
容器。对于动态加载程序集,我们建议使用新的
AssemblyLoadContext类。
What should I use instead? AppDomains were used for different purposes. For code isolation, we recommend processes and/or containers. For dynamic loading of assemblies, we recommend the new AssemblyLoadContext class.
由于无法使用容器,因此看起来像唯一的选择是在单独的进程中运行沙盒。
Since you cannot use containers, it looks like the only option is to run your sandbox in a separate process.
源:
这篇关于.net核心中的沙箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!