Dean Hiller
Dean Hiller

Reputation: 20182

How to have dlls copied to lib folder and exe to bin folder and make it still work?

Ideally, we would like our automated build(using jenkins to call a build.bat which calls msbuild right now) to end up with a zip file with these folders

How to get Visual Studio to put all the files in the correct place such that the exe will still work correctly as right now the dlls seem to have to be in the same folder for it to work :( :(. and I do not want ot install dlls in the GAC. I just want the above structure so a user can unzip and run the program immediately.

I want this to work in visual studio when I run in debug mode and when I run the build outside visual studio as well (I can add zipping it all up easily enough in the build.bat if I have to).

thanks, dean

Upvotes: 2

Views: 445

Answers (2)

Quintonn
Quintonn

Reputation: 790

You can use "Probing" in your app.config file.
https://msdn.microsoft.com/en-us/library/823z9h8w(v=vs.110).aspx
I just tested it, and it works.

Upvotes: 0

SLaks
SLaks

Reputation: 887195

You need to handle the AppDomain.AssemblyResolve event and call Assembly.Load with a path to the lib directory.

Note that you must add the handler before JITting any methods or classes that use types from the assemblies you need to load.

Upvotes: 1

Related Questions