Tadas Stra
Tadas Stra

Reputation: 575

Deploy C# DLL library with dependecies

I have an application (let's call it A) which loads the DLL plugins from the folder Plugins. I have created a plugin dll (let's call it B). My plugin dll is written in C# and have some dependencies like CEFSHARP DLL. The only way the Application A can load my Plugin dll B if I will copy all the CefSharp DLL needed dependencies to Application A folder. My question would be:

How to make an install setup file so it would install necessary dependencies to some kind of folder and Application A would know where those are? Plugin B don't have to be transferred to Plugins folder during the install. Is it even possible?

Thanks in advance!

Upvotes: 0

Views: 307

Answers (1)

Thomas Weller
Thomas Weller

Reputation: 59289

If the application is implemented well, it should come with an app.config (that's the name in Visual Studio) or myapp.exe.config (that's the name after it was compiled) file that searches for dependent DLLs in the plugin folder, like

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="plugins" />
    </assemblyBinding>
  </runtime>
</configuration>

Your plugin would then have all its dependencies side-by-side and there's no need to put them into the application's installation directory.

With InnoSetup you could do it as follows:

  • let the user select the application A installation directory (ideally: use a Pascal script to detect it automatically, e.g. from Registry and do not let the user choose it)
  • install the dependencies into the selected directory
  • install the plugin into the plugins subdirectory

Here are the relevant lines of an InnoSetup script:

[Setup]
DefaultDirName={pf}\App A
[Files]
Source: "./myplugin.dll"; DestDir: "{app}/plugins"; Flags: ignoreversion
Source: "./dependency.dll"; DestDir: "{app}"; Flags: ignoreversion

Upvotes: 1

Related Questions