0

This problem is about using wholly unmanaged C++ without using deprecated means.

I am hosting the CLR in C++ calling (in order):

  1. CLRCreateInstance to get an ICLRMetaHost* .
  2. The ICLRMetaHost method GetRuntime to get an ICLRRuntimeInfo* for v4.0.30319 .
  3. The ICLRRuntimeInfo method GetInterface to get an ICLRRuntimeHost* .
  4. The Start method of ICLRRuntimeHost to start the host.

Back in the day a different route would have produced a (now deprecated) ICorRuntimeHost* and the result of calling its GetDefaultDomain method would be used to get an _AppDomain* giving unmanaged access to the default AppDomain.

https://learn.microsoft.com/en-us/dotnet/api/system._appdomain

This _AppDomain* is what I want, but ICLRRuntimeHost has no analog of GetDefaultDomain.

The new arrangements for CLR hosting that don't use ICorRuntimeHost don't seem to support getting an _AppDomain* by any means I saw from searching online documentation.

How is the needed _AppDomain* obtained nowadays?

Sturt
  • 204
  • 7
  • AppDomains no longer exist in .NETCore (aka .NET5 and up). So as long as you need one, you might as well use the deprecated interface. Hosting in the current .NET version is described [here](https://learn.microsoft.com/en-us/dotnet/core/tutorials/netcore-hosting). – Hans Passant Dec 08 '22 at 02:14
  • I'm concerned with .NET framework 4.8 (currently) Windows only. – Sturt Dec 08 '22 at 02:41
  • Why do you need that in the first place? You can execute code in the default appdomain using ExecuteInAppDomain(host->GetCurrentAppDomainId()...) or ExecuteInDefaultAppDomain with an external assembly. Otherwise, IMHO, the fact this API deprecated is not a problem since .NET framework is frozen in stone and will never evolve. – Simon Mourier Dec 09 '22 at 11:39
  • Respectfully it's otherwise: have Microsoft removed the ability to get a System._AppDomain except through a deprecated part of the unmanaged CLR hosting API? It's defined for a very specific purpose and is not itself deprecated. I'm concerned that the .NET Framework may devolve by having apparently vital deprecated parts removed, even while the rest remains frozen in stone. – Sturt Dec 09 '22 at 14:48

0 Answers0