gpt4 book ai didi

.net-core - 为什么微软将 AppDomain 带回 .NET Core 3.0?

转载 作者:行者123 更新时间:2023-12-04 16:28:16 36 4
gpt4 key购买 nike

从内存中,微软拿了 AppDomain离开了,这个机制已经被关闭了。

现在突然发现AppDomain回来了:

Assembly System.Runtime.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\dotnet\packs\Microsoft.NETCore.App.Ref\3.0.0\ref\netcoreapp3.0\System.Runtime.Extensions.dll



该程序集包含 AppDomain 类。

这是我的问题:为什么?

最佳答案

Porting to .NET Core

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.



此外

Of course, just because something isn’t available in .NET Core today doesn’t mean we discontinued it. In most cases, it simply means we haven’t had the time to investigate whether porting would make sense or didn’t think it was relevant to the application models .NET Core currently offers. Thus, this is an area we’re highly interested in getting your feedback.



那么实际上支持什么?

AppDomain Class

On .NET Core, the AppDomain implementation is limited by design and does not provide isolation, unloading, or security boundaries. For .NET Core, there is exactly one AppDomain. Isolation and unloading are provided through AssemblyLoadContext. Security boundaries should be provided by process boundaries and appropriate remoting techniques.

It's there for certain tasks, however it's not supported in a lot of ways.



适用于

.NET Core

  • 3.0 2.2 2.1 2.0

.NET Framework

  • 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6 4.5.2 4.5.1 4.5 4.0 3.5 3.0 2.0 1.1

.NET Standard

  • 2.1 2.0


那么如果你使用了不受支持的东西会怎样呢?

它要么不存在,要么你得到一个很大的令人讨厌的证据 throw new NotSupportedExceptionPlatformNotSupportedException取决于何时何地

进一步阅读
  • https://github.com/dotnet/standard/blob/master/docs/faq.md#is-appdomain-part-of-net-standard
  • https://github.com/dotnet/standard/blob/master/docs/faq.md#why-do-you-include-apis-that-dont-work-everywhere
  • 关于.net-core - 为什么微软将 AppDomain 带回 .NET Core 3.0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58424625/

    36 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com