Help needed with unloading .DLL's from AppDomain - Still not working even with ShadowCopy

前端 未结 3 1535
执笔经年
执笔经年 2020-12-21 07:01

I am trying to do the following. App A is the \"mother app\". It stays open. App B is just a .DLL where I write some classes that are derived from an interface specified in

相关标签:
3条回答
  • 2020-12-21 07:46

    Your code still runs in the mother AppDomain, as you're pulling in assemblies and types into there. Any code should run in the spawned domain. I've shown one way to set something like that up on my website : A simple way to start your code in a different AppDomain

    I'm not 100% sure on that but that's certainly one step you'll have to undertake

    Update

    In terms of the solution presented there, your instantiation of a runner would happen in an inheritor of DomainLifetimeHook. The infrastructure shown ensures that the Start and Stop methods run in the AppDomain created by the class AppDomainExpander. That Expander is the class that creates the new domain, hence your domain setup should go in the Create method of the domain.

    0 讨论(0)
  • 2020-12-21 07:53

    The main problem is where you do:

    Type type = assm.GetType("TestClient." + typeName);
    

    This is happening in App A's main AppDomain, and the consequence is that the main AppDomain locks App B's assembly .dll

    The link in flq's answer to his blog post should work for you.

    0 讨论(0)
  • 2020-12-21 07:56

    The type has to be loaded into the main appdomain as soon as you unwrap the ObjectHandle. To work properly, you need to operate on the non-unwrapped ObjectHandle.

    0 讨论(0)
提交回复
热议问题