hcdDefaultDomain and different path

Hello, I developed a plugin visual containing CefSharp, for the used one, I retrieved the last version of Hydra for Delphi7, implementing the option “hcdDefaultDomain” during the LoadModule.
My plugin is not in the same directory as my application, so it does not work, because it tells me not to find the assembly “RemObjects.Hydra.dll”. Of course, she is present.
If I remove the option “hcdDefaultDomain” my plugin loads well, but CefSharp does not work.
How can I tell my Hydra plugin to search its assemblies in its directory and not in my application?

I performed a test, if I put RemObjects.Hydra.dll in the directory of my application, everything works fine, my plugin finds the other assemblies in its own directory.

But for me, it’s not a solution. Do you have a idea to define the work directory of my plugin ?

1 Like

you can put RemObjects.Hydra.dll into GAC. after this it should be found in any case

I would like my application to be as unobtrusive as possible, and so everything in its repertoire. I already have to put RemObjects.Hydra.dll in the directory of my plugin, if I do not really want to copy it everywhere to make it work. So is there no way to ensure that the loading of my plugin is in its directory?

You could try manually loading the dll with Assembly.Load and a full path?

I tried to overload AppDomain.Current.ResolveAssembly, but unfortunately, my plugin does not even load, I do not go in it.

Your plugin class references a type defined in the RemObjects.Hydra.dll assembly. So .NET CLR cannot load this type, so there is no chance to overload the AppDomain.Current.ResolveAssembly handler, unless you’ll create one more plugin where you’ll call a method to actually set this event handler for the default AppDomain (but that is an overkill)

This is the way .NET resolves references: https://docs.microsoft.com/en-us/dotnet/framework/deployment/how-the-runtime-locates-assemblies

In short words - when the plugin assembly is loaded, .NET tries to load referenced assemblies from GAC, then from the plugin’s assembly folder.

What can be done here?

  1. Put the RemObjects.Hydra.dll assembly into GAC (this makes the deployment process a little trickier than just copying all the assemblies)
  2. Put the RemObjects.Hydra.dll assembly next to plugin (actually this is the best approach)
  3. Explicitly load the RemObjects.Hydra.dll assembly before the plugin is loaded. This can be a bit tricky as this will work only for default domain-loaded plugins and you’ll have to ensure that the versions of the referenced assembly and the one you try to load do match.

I tried the approach 2. But as I say, my plugin does not see the DLLs. Or is it up to Delphi to charge it before?

Hi,

we will review this case

Thanks, logged as bugs://83423

Hi,

pls update

  • uHYCLRManagedModuleController.pas:
     procedure THYManagedModuleController.InitializeAppDomain(aName: string; aBasePath: string);
    ..
      hcdDefaultDomain: fAppDomain := THYClrAppDomain.CreateWithDefaultDomain(aBasePath); //changed
    
  • uHYCLRWrappers.pas:
    THYClrAppDomain = class
    ..
     constructor CreateWithDefaultDomain(const BasePath: UnicodeString = '';const InitHydraCore: boolean = true); //changed
    
    ..
    
    constructor THYClrAppDomain.CreateWithDefaultDomain(const BasePath: UnicodeString; const InitHydraCore: boolean); //changed
    ..
     fAppDomain := HYClr.GetDefaultDomain;
     if BasePath <> '' then  fAppDomain.AppendPrivatePath(BasePath); //added
    

after this open BuildPackages_D## group package and recompile all installed Hydra packages.

bugs://83423 got closed with status fixed.

Thank you for this correction, do you have any idea of the availability date of the next version including this fix?

I can not build the solution, I have an error because of DevExpress components, probably a conflict with the ones we use. Could you provide me with compiled packages?

Hi,

have you recompiled all installed packages from BuildPackages_D##?
if you have error during recompiling Hydra packages, try to disable Hydra_Core package in IDE:

and then recompile packages again

Yes, I have rebuild BuildPackages_D7.bpg.
I have a error in uHYDXUI.pas from Hydra_DX_D7.bpl, with message “[Error] uHYDXUI.pas (225): Undeclared identifier: ‘GetAsBitmap’”
I think it’s due to the fact that I already have DevExpress components, but an old version.

I wonder, what version of Hydra you are using?
afaik, we don’t compile HY_DX automatically during installing hydra…
as a result, users should manually compile and install it…

I use the version 6.2.101.1233
You say me to open BuildPackages_D7.bpg in \Hydra for Delphi\Source, and in, I have :

  • hydra_Core_D7.bpl
  • hydra_DX_D7.bpl
  • hydra_TB2K_D7.bpl
  • hydra_RO_D7.bpl
  • hydra_IDE_D7.bpl
  • hydra_RO_IDE_D7.bpl

hmm, you shouldn’t have any problems with rebuilding Hydra_DX_D7 then.
try to uncheck Hydra_Core_D7 in IDE->Component->Install Packages. it will temporary unload all hydra packages and rebuild all Hydra packages

also check that you have path in Delphi settings for DX packages and units

yes i have.