简体   繁体   English

最佳实践如何使用.net隔离动态代码/程序集

[英]Best Practice How to isolate dynamic code / assemblies with .net CORE

With .NET 4.5 I created an extensible web application. 使用.NET 4.5,我创建了可扩展的Web应用程序。 With executes at run-time certified code from third parties. With在运行时从第三方执行经过认证的代码。

For this, I use app domains and inter-process communication. 为此,我使用应用程序域和进程间通信。

Now I saw that a lot of technologies I used for this aren't any more supported in .NET core 现在我看到.NET核心不再支持我用于此目的的许多技术

like: 喜欢:

  • AppDomains 应用程序域
  • Remoting 远程处理
  • BinarySerzializers BinarySerzializers

For most of them, there are obvious solutions. 对于其中大多数而言,都有明显的解决方案。 But the remove of AppDomains is a tough thing. 但是删除AppDomains是一件困难的事情。

If I understand it right I should use processes. 如果我理解正确,则应该使用流程。 But if my application has about 100 Extensions (multiple customers)? 但是,如果我的应用程序具有大约100个扩展(多个客户)? This would mean I would have to create 100 processes (microservices) or at least group some together in microservices. 这意味着我将不得不创建100个进程(微服务),或者至少将一些组合在微服务中。

But I don't feel very comfortable with either one. 但是我对两者都不满意。 In the one way, I would end up with hundreds of processes. 以一种方式,我将要完成数百个过程。 And if I group I could still get influences between them. 如果我分组,我仍然可以在他们之间获得影响。

So what would be the right way to choose? 那么正确的选择方式是什么?

One possible solution may be to use AssemblyLoadContext in place of AppDomains. 一种可能的解决方案是使用AssemblyLoadContext代替AppDomain。

This isn't a direct replacement for AppDomains and the level of isolation that gives you, but it may be good enough for your needs - it allows you to use the equivalent of AppDomain.LoadFile and AppDomain.ResolveEvent to give you assembly loading isolation. 这不是AppDomains以及提供给您的隔离级别的直接替代,但这可能足以满足您的需求-它允许您使用等效的AppDomain.LoadFileAppDomain.ResolveEvent来给程序集加载隔离。

There is not any real documentation around this at the moment, but there is an issue for doing just that here: https://github.com/dotnet/coreclr/issues/5463 目前没有任何实际的文档,但是在此处执行此操作存在一个问题: https : //github.com/dotnet/coreclr/issues/5463

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM