With a lot of experimentation, I got the following:
internal class AssemblyResolver : MarshalByRefObject { static internal void Register(AppDomain domain) { AssemblyResolver resolver = domain.CreateInstanceFromAndUnwrap( Assembly.GetExecutingAssembly().Location, typeof(AssemblyResolver).FullName) as AssemblyResolver; resolver.RegisterDomain(domain); } private void RegisterDomain(AppDomain domain) { domain.AssemblyResolve += ResolveAssembly; domain.AssemblyLoad += LoadAssembly; } private Assembly ResolveAssembly(object sender, ResolveEventArgs args) { // implement assembly resolving here return null; } private void LoadAssembly(object sender, AssemblyLoadEventArgs args) { // implement assembly loading here } }
The domain is created as follows:
AppDomainSetup setupInfo = AppDomain.CurrentDomain.SetupInformation; setupInfo.DisallowApplicationBaseProbing = true; domain = AppDomain.CreateDomain("Domain name. ", null, setupInfo); AssemblyResolver.Register(domain);
Sorry, I canβt share the code to allow and download assemblies. Firstly, it does not work yet. Secondly, in this context it will be too much and too specific to share with the general public.
I will load the object structure, which is serialized along with the assemblies required for deserialization from a single file. For this, I really deserve to add .dll directly.
No answer
source share