1

Scenario: Foreign application host (.exe) loads my assembly (some kind of a addin) which in turn needs to load the resource assemblies.

For now this works only when i copy the resource assemblies into the main folder of the host application. BUT i wanna leave them in my specific installation folder. How to achieve this?

Normally when using my application i place the resource assemblies in app.exe\langcode folder.

Regards

Martin.Martinsson
  • 1,894
  • 21
  • 25
  • Do you have a first called method (or static ctor) that won't cause the resources to be searched? In that case add your own `AppDomain.AssemblyResolve` (in `CurrentDomain`, I suppose) to manually load them from the _right_ folder (which you obtain from assembly location of `GetExecutingAssembly()`) – Adriano Repetti Dec 22 '16 at 15:10
  • Cannot use `this.assembly = Assembly.LoadFile(file_name);`? – McNets Dec 22 '16 at 15:11
  • The runtime uses standard .NET mechanism to load resource assemblies. Which looks for a folder named . In my scenario some other application loads may dll which needs to locate may resources! Is know clearer? – Martin.Martinsson Dec 22 '16 at 15:12
  • is the foreingen app configurable or it does require all .dll in on specific folder? – McNets Dec 22 '16 at 15:25
  • The foreign app has an app.config! The only solution may be to write a reference to the satelite assemblies into it?!? You mean that? – Martin.Martinsson Dec 22 '16 at 15:38

1 Answers1

0

In configuration files you can use the runtime section to configure this. Otherwise you need to use AppDomain.AssemblyResolve which is most likely the case in your scenario.

<runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
              <assemblyIdentity name="[DLL Name]" publicKeyToken="[Token]"/>
              <codeBase version="[Version/Range]" href="langcode/[DLL Name].dll"/>
          </dependentAssembly>
      </assemblyBinding>
</runtime>

Working with AppDomain.AssemblyResolve event

Community
  • 1
  • 1
user1628733
  • 156
  • 1
  • 8