I have a Delphi 2007 Project which calls 2 C# dlls, through Hydra.
While the first dll successfully loads, the second one throws a Assembly.GetTypes() error, no matter we have or we dont have Assembly resolver. Can someone help pls.
My delphi Screen throws exception during Hydra Load:.
The THYManagedModuleController throws an Assembly.GetTypes error at
THYManagedModuleController.CreateManagedControllerInstance
lTypes := fAssembly.GetTypes();
Even if the dll is loaded without the first dll, we would still have this exception.
Any idea would be much appreciated. Thanks.
This issue is with some of the dlls not resolved.
As of now I have 2 DLLS, each of which have a set of referenced dlls including remobjects. Some of them are common for both dlls and more dlls expected in future similar to these.
Is there any efficient way to add assembly resolver, that could be common to totally different dlls, and could be updated as and when required? I do not want it to be in the source folder of the plugin due to project reasons. Preferable embedded.
Unfortunately there is no such method in Hydra, but you can do this manually by changing source files:
you need to modify uHYCLRManagedModuleController.pas that is shipped with Hydra, edit following method:
constructor THYManagedModuleController.Create(aFilename: string; aSearchPath: string=’’; const InNewAppDomain: boolean = true);
was:
[...]
if fOwnsAppDomain or fAppDomain.IsAssemblyInBasePath(fFileName) then
fAssembly := fAppDomain.LoadAssembly(ExtractFileName(aFilename))
else
fAssembly := LoadAssemblyFromCore(fFileName);
[...]
new:
[...]
if fOwnsAppDomain or fAppDomain.IsAssemblyInBasePath(fFileName) then
fAssembly := fAppDomain.LoadAssembly(ExtractFileName(aFilename))
else
fAssembly := LoadAssemblyFromCore(fFileName);
try
fAssembly.CreateInstance_2('Your.Custom.Namespaces.AssemblyResolver', true);
except
end;
[...]
This code will allow you to create an instance of a AssemblyResolver class before Hydra core will attempt to access types information and it will be able to resolve your embedded assemblies properly.