.net 核心中的沙盒

Sandboxing in .net core

我想知道如何在 .net core 中实现沙盒,因为 .net core 不支持 appdomains。另外,我不能使用虚拟化或 docket 容器,因为这些东西在我的目标机器上不可用。

根据 .NET Core 文档,您的选择似乎有点受限。

Free of problematic tech. .NET Core doesn’t include certain technologies we decided to discontinue because we found them to be problematic, for instance AppDomain and sandboxing. If the scenario still makes sense for .NET Core, our plan is to have replacements. For example, AssemblyLoadContext replaces AppDomains for loading and isolating assemblies.

App Domains

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.

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.

由于您不能使用容器,看来唯一的选择是 运行 您的沙盒在一个单独的进程中。

来源: https://blogs.msdn.microsoft.com/dotnet/2016/02/10/porting-to-net-core/