-1

I'm in Visual Studio 2019, and I'd like to deploy all the DLLs in my project to a DLL folder and have the exe in another folder. I don't see an option for that really though. Can I do that?

  • 3
    There is no simple way to do that. You could add an AssemblyResolve handler. – SLaks May 16 '19 at 16:29
  • Do it as a post build step. – Señor CMasMas May 16 '19 at 16:30
  • Consider a ClickOnce deployment. – Robert Harvey May 16 '19 at 16:31
  • Do what as a post build step... the AssemblyResolve handler? Or just the copy of the DLLs to the other folder. If I do that, won't the exe not be able to find them? – Sean McCown May 16 '19 at 16:31
  • 1
    I think you'll have to do both. – Robert Harvey May 16 '19 at 16:32
  • Possibly the [assemblyBinding configuration element](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/assemblybinding-element-for-runtime); specifically, the codeBase option. – Kenneth K. May 16 '19 at 16:32
  • Both will be necessary. .Net expects assembly dependencies to be in the same folder or in the GAC. You would have to (a) write a post-build step to move the DLLs to the desired folder, then (b) tell the app domain how to find those DLLs. –  May 16 '19 at 16:35
  • You can load any assembly at runtime using nothing but the path. https://stackoverflow.com/questions/465488/can-i-load-a-net-assembly-at-runtime-and-instantiate-a-type-knowing-only-the-na – Señor CMasMas May 16 '19 at 16:36

1 Answers1

2

As described in the documentation, assemblies are located using a particular algorithm. One part of that algorithm is to check the configuration file for codeBase elements. These elements define a specific location (per assembly and version) to search for a particular assembly.

Alternatively, you can set the privatePath value for the probing element. This would affect all DLLs for your application whereas the above could target specific DLLs.

So you would set up a post-build step to copy your DLLs (and/or EXE) to the destination folder, and update your app.config to have the appropriate <codeBase> or <probing> elements which point to that destination folder.

Kenneth K.
  • 2,987
  • 1
  • 23
  • 30