Category : appdomain

The following simple code can be directly run in Visual Studio C++ console project. It will loop forever because the NextDomain will always return the same IUnknown * According to Microsoft, it should return NULL if the enumeration reaches end. See https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/hosting/icorruntimehost-nextdomain-method However, the NULL is never reached. It seems that it never return the ..

Read more

Why CSharp.dll gets loaded into DefaultDomain and how to avoid this? Console::WriteLine(AppDomain::CurrentDomain->FriendlyName); auto assemblies = AppDomain::CurrentDomain->GetAssemblies(); for (int i = 0; i < assemblies->Length; ++i) Console::WriteLine(assemblies[i]->GetName()); AppDomain^ domain = AppDomain::CreateDomain(ToMngd(L"MyDomain")); ObjectHandle^ handle = domain->CreateInstance(ToMngd(L"CSharpDll"), ToMngd(L"CSharpDll.Class1")); Console::WriteLine(domain->FriendlyName); assemblies = domain->GetAssemblies(); for (int i = 0; i < assemblies->Length; ++i) Console::WriteLine(assemblies[i]->GetName()); AppDomain::Unload(domain); Console::WriteLine(AppDomain::CurrentDomain->FriendlyName); assemblies = AppDomain::CurrentDomain->GetAssemblies(); for ..

Read more

I have the following setup App -> native.dll -> native/clr.dll -> .net.dll App loads/unloads native.dll before for every call. native.dll in turn uses code like this to load .net.dll: Assembly^ AssemblyLoader::Load(Object^ sender, ResolveEventArgs^ args) => Assembly::LoadFrom(AssemblyPathHolder::Value); … _resolveEventHandler = gcnew ResolveEventHandler(this, &AssemblyLoader::Load); AppDomain::CurrentDomain->AssemblyResolve += _resolveEventHandler; … AppDomain::CurrentDomain->AssemblyResolve -= _resolveEventHandler; Appeared that removing the handler doesn’t ..

Read more