After the call
Managed c1 = new Managed();
Your manage.dll shell will be loaded into the main application domain of your application. Until the unmanaged domain material is removed from static.lib, they will be transferred to other domains. Instead of creating a separate process, you just need to be sure (before each call) that the manage.dll file is not loaded into any application domain.
Compare with this
static void Main(string[] args) { { AppDomain ad = AppDomain.CreateDomain("NewDomain"); Managed c = ad.CreateInstanceAndUnwrap(a.FullName, typeof(Managed).FullName) as Managed; int val2 = c.CallLibFunc();
IMPORTANT: If you add only one JIT compiler, download the manage.dll file and the magic will disappear.
static void Main(string[] args) { { AppDomain ad = AppDomain.CreateDomain("NewDomain"); Managed c = ad.CreateInstanceAndUnwrap(a.FullName, typeof(Managed).FullName) as Managed; int val2 = c.CallLibFunc();
If you do not want to depend on such lines, you can create another ManagedIsolated.dll shell that will reference the manage.dll file and make each call in a separate domain with domain unloading immediately after the call. The main application will depend only on the types of ManagedIsolated.dll, and Managed.dll will not be loaded into the main domain of the application.
It seems like a trick, but maybe it will be useful for someone. `
Vladimir
source share