Hi,
I'm trying to write a CLR host (.NET 4) to run an existing .NET product from C++.
I've implemented IHostAssemblyStore::ProvideAssembly and it works most of time.
However, I can't make it work in the following scenario:
Suppose there is an assembly called TestDep.
Running:
Assembly.Load("TestDep, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
from my hosted code works (TestDep.dll is resolved by my ProvideAssembly(..) implementation).
However, running:
Assembly.Load("TestDep, Culture=neutral");
does not. ProvideAssembly is not even called.
This is from the fusion log:
LOG: Fusion is hosted. Check host about this assembly. LOG: Assembly is not in CLR Loaded list. Asking host assembly store. LOG: Input is partial name. Skip host assembly store lookup. ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
I tried to fix this by registering to AppDomain.AssemblyResolve event with this code:
if (args.name == "TestDep, Culture=neutral") {
return Assembly.Load("TestDep, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nulll");
}
But it still doesn't work. Now fusion log contains this:
LOG: The same bind was seen before, and was failed with hr = 0x80070002. ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
I tried to disable binding caching by putting:
<runtime><disableCachingBindingFailures>1</disableCachingBindingFailures></runtime>
In my app.config but it had no affect.
Adding
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><qualifyAssembly partialName="TestDep" fullName="TestDep, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/></assemblyBinding>
did not help either.
The only workaround I found was to call
Assembly.Load("TestDep, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
Before running the hosted code.
Is there a better solution? How am I supposed to support partial binding in my CLR host?
Is it possible to disable binding caching from code?
Of course I can't modify the application I'm trying to host (change partial to full bindings).
Thanks!