AppDomainToolkit icon indicating copy to clipboard operation
AppDomainToolkit copied to clipboard

Appdomain is sometimes loading dlls from Parent directory of PrivateBinPath and sometimes from PrivateBinPath

Open CaroleneP opened this issue 7 years ago • 4 comments

Hi,

I am using AppdomainToolKit and my code goes as follows:

         string basePath = "C:\\Uploader\\Bin";
         var setupInfo = new AppDomainSetup();
         setupInfo.ApplicationName = "SomeName";
         setupInfo.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
         setupInfo.PrivateBinPath = Path.Combine(basePath, "PluginFolder\\Plugin.dll");
         try
          {
              var context = AppDomainContext.Create(setupInfo);
              context.LoadAssembly(LoadMethod.LoadFrom, Path.Combine(basePath,                                                                                                                       
                                                   "PluginFolder\\Plugin.dll"));
              return context.Domain;
          }

I see that Appdomain is sometimes loading dlls from basePath (C:\Uploader\Bin) and sometimes from PrivateBinPath.

The exact issue is Plugin.dll is using Polly.dll which is signed and PluginFolder(C:\Uploader\Bin\PluginFolder) contains it. And C:\Uploader\Bin (basePath) is holding another Polly.dll which is unsigned. Now when the Plugin.dll is loaded into Appdomain its looking for Polly.dll in basePath (C:\Uploader\Bin) instead of C:\Uploader\Bin\PluginFolder and throws exception. Am i doing the right thing in my code?

Please help me to understand the concept behind this issue and help me resolve it.

CaroleneP avatar Jun 20 '18 18:06 CaroleneP

Hey @CaroleneP. Would you mind attaching a small zipped workspace (or share it somewhere) so I have a way of reproducing your problem. It seems you're in pretty deep and I'm having trouble following you.

jduv avatar Jun 21 '18 00:06 jduv

@jduv It took sometime to prepare the sample application that exactly resembles the scenario in my live project. Please let me know where to upload.

CaroleneP avatar Jun 27 '18 13:06 CaroleneP

@CaroleneP Email it directly to me or share it in a google drive with link sharing on. I'll pull it and give it a look.

jduv avatar Jun 29 '18 01:06 jduv

Dear Jeremy,

Please find the email attached which contains google drive link to our code.

CallerService folder contains the main solution. It loads the plugin from the folder “TestPlugin-1.0.0.0”. The plugin package is built using TestPluginSample solution. Also please have a look at the screenshot which is taken from ProcessExplorer tool available online. We can see that the polly dll is being loaded from CallerService bin (which is the ApplicationBase) instead of plugin bin “TestPlugin-1.0.0.0”. As per my problem description in Github the CallerService is using unsigned polly and TestPlugin is using signed polly. Ideally TestPlugin.dll should refer to the dlls from “TestPlugin-1.0.0.0” folder instead of ApplicationBase but that’s not the case as per screenshot. If I set this property setupInfo.PrivateBinPathProbe = "ProbingForAssembliesInPrivateBinPath"; then the plulgin loads the dlls from “TestPlugin-1.0.0.0” but still I could see that our realtime application has two references for one dll. One from ApplicationBase and another from Plugin directory “TestPlugin-1.0.0.0”. Could you please explain what could be the reason for this.

Regards, Carolene

From: Jeremy Duvall [mailto:[email protected]] Sent: Friday, June 29, 2018 6:32 AM To: jduv/AppDomainToolkit Cc: Papabathini, Carolene (SHS TI DC IND SV DEV TP1); Mention Subject: Re: [jduv/AppDomainToolkit] Appdomain is sometimes loading dlls from Parent directory of PrivateBinPath and sometimes from PrivateBinPath (#28)

@CarolenePhttps://github.com/CaroleneP Email it directly to me or share it in a google drive with link sharing on. I'll pull it and give it a look.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/jduv/AppDomainToolkit/issues/28#issuecomment-401216944, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AiwgMec6WS_k6Rc3GTtmqZUQ7BukDwVRks5uBXx_gaJpZM4UvuwP.

CaroleneP avatar Jul 03 '18 11:07 CaroleneP