Best Practice How to isolate dynamic code / assemblies with .net CORE
Asked Answered
P

1

6

With .NET 4.5 I created an extensible web application. With executes at run-time certified code from third parties.

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

like:

  • AppDomains
  • Remoting
  • BinarySerzializers

For most of them, there are obvious solutions. But the remove of AppDomains is a tough thing.

If I understand it right I should use processes. But if my application has about 100 Extensions (multiple customers)? This would mean I would have to create 100 processes (microservices) or at least group some together in microservices.

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?

Preprandial answered 27/6, 2016 at 7:52 Comment(0)
F
2

One possible solution may be to use AssemblyLoadContext in place of AppDomains.

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.

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

For answered 27/6, 2016 at 12:6 Comment(3)
worse a look but as you said it isn't the same isolation level. I just wonder if the people at the dotnet core just ignore this needs or if I oversee somethign...Preprandial
It may well be something that comes back in as more of the full framework is added to netstandard - they don't explicitly mention AppDomain but if you haven't already, this article is worth a look as a vague roadmap: blogs.msdn.microsoft.com/dotnet/2016/05/27/…For
I just want to underscore what @For said: AssemblyLoadContext does not provide perfect isolation. It is not difficult for an "isolated" assembly to alter private state in other assemblies through reflection. It seems that separating processes is the only sure-fire way to prevent this.Silvan

© 2022 - 2024 — McMap. All rights reserved.