|
Hi,
I'm currently writing some kind of managed/unmanaged DependencyWalker in C#. I already shipped around many cliffs like enumerating thenative dependencies of an assembly without having reflection available.
My current problem is reflection only loading of the managed dependencies of an assembly in another folder. Given a file structure like
\walker\walker.exe
\assemblies\assembly1.dll
\assemblies\assembly2.dll
\assemblies\native.dll
my walking application is walker.exe. The user selects the managed assembly \assemblies\assembly1.dll and it gets loaded via Assembly.ReflectionOnlyLoadFrom(). That works fine. I can now enumerate its referenced assemblies and its imported native dlls.
Let's assume now that assembly1 depends on assembly2 and that depends on the native dll.
When I now try to load the referenced assemblies by full name, I get load failures, as they are lying in the \assemblies folder and my current AppDomain is \walker based.
I subscribed to the ReflectionOnlyAssemblyResolve event and get callbacks for only some of the assemblies. I fix them and they can be ReflectionOnlyLoaded. For the remaining assemblies I get FileNotFoundExceptions. I suspect these are dlls with native imports that can only be resolved running from \assemblies.
I experimented with creating a new AppDomain with different base directorybut didn't come further. As AppDomain has only Load() and no ReflectionOnlyLoad()/ReflectionOnlyLoadFrom() I would have to execute code in the other domain. For that I have to load my code into the other domain, so I have to load my exe there. But AppDomain has not LoadFrom() either, so I'm stuck if I don't want to copy an assembly there or emit code into the other domain.
Any ideas?
Cheers,
Thomas
|