I'm trying to figure out how to load the AppDomainManager assembly in a managed clr hosting scenario from a folder different from the native .exe file.
Has anyone done an IHostAssemblyStore::ProvideAssembly implementation, that will load the AppDomainManager assembly from a folder, and would like to share it?
I'm new to this WinApi/OLE/whatever programming, and I have no idea how to get an IStream* from a file on disk in c++.
Or is there another way load the AppDomainManager for the DefaultDomain from an arbitrary folder?
SHCreateStreamOnFile will load the assembly from disc into an IStream, e.g.:
Pitfall:
The CLR will call your ProvideAssembly implementation several times for one assembly.
Be sure to use the postPolicyIdentity in the AssemblyBindInfo to return the "right" bits at the right call considering the processor architecture:
If your assembly was build
"Any CPU"
but you return it when the postPolicyIdentity contains e.g."processorarchitecture=amd64"
at the end theruntimeHost->Start()
call will fail.Instead you have to return
COR_E_FILENOTFOUND (0x80070002)
until the processorarchitecture matches.