0

When you add a reference to a DLL, you have the option to set the copy local property to True/False. I have looked online and on stackoverflow for a way to specify where that output goes to? I basically would like my assembled exe to be able to reference the dll inside another folder.

My exe would be in the normal root:

/root  

but I would want my dll to live inside a folder:

/root/dll_files 

for example. Is there any way to achieve this that will work for all dll files?

Keep in mind that I want this to be a dynamic path. I want the dlls to always be in the folder /DLL in reference to the loaded exe

Update

I did try modifying my app.config file to be the following:

<?xml version="1.0" encoding="utf-8" ?>
 <configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="bin\DLLs" />
    </assemblyBinding>
  </runtime>
 </configuration>

but the dll's still go into /bin and not /bin/DLLS

Another try

Since I am doing this in vb.net and not C#, I also tried making a main sub:

Public Sub Main()
    AppDomain.CurrentDomain.AppendPrivatePath("DLLS")
    Application.EnableVisualStyles()
    Application.SetCompatibleTextRenderingDefault(False)
    Application.Run(New Form1)

End Sub

I then made this my startup module. The module itself launches fine but the dlls still go into the root path, not /DLLS

Eric F
  • 899
  • 2
  • 21
  • 45
  • 1
    Your EXE and any libraries it uses are stored in your EXE project's bin\Debug directory. Which is a very good place, it ensures that you can debug your program and all of the files that the CLR needs to find at runtime are in a single directory. You can technically give it a hard time to find those files. There is excessively little point to that, it requires a config file with the `` element to help the CLR find them. – Hans Passant Apr 11 '16 at 17:40
  • 1
    Possible duplicate of [Set Custom Path to Referenced DLL's?](http://stackoverflow.com/questions/1892492/set-custom-path-to-referenced-dlls) – Visual Vincent Apr 11 '16 at 18:05
  • @HansPassant I don't want to copy everything to a separate folder, just the dlls. Can you please elaborate as to how I go about this? – Eric F Apr 11 '16 at 18:33
  • @VisualVincent I tried what they showed there as shown above but it did not work. See my edit above – Eric F Apr 11 '16 at 18:35
  • @HansPassant I did try probing as shown in my edit but it still doesn't place the dlls correctly. Any idea as to what I am missing? – Eric F Apr 11 '16 at 19:38
  • When you say "but the dll's still go into /bin and not /bin/DLLS", do you mean that these are your own DLL's being compiled as part of the same Solution? In which case, have you experimented with "Build output path" setting in the Compile tab of each DLL project's Properties? – rskar Apr 11 '16 at 20:38
  • @rskar I want the exe to go inside the /bin folder but the dlls to go inside the /bin/DLLS folder. The build output path field applies to the entire solution not just the dlls. I only want the dll files to go into the /bin/DLLS folder – Eric F Apr 12 '16 at 12:36
  • For what it's worth, I can aver that the "Build output path" (in the "Compile" tab of the "Properties" window of a Project) isn't Solution-wide; it is indeed a per-Project setting for Visual Basic (Visual Studio 2013). Be mindful of the "Configuration" mode (Debug, Release, etc.), since this setting is also of a per-Configuration basis. If you still see your DLL's showing up alongside your EXE, be sure you have "Copy Local" set to False for the relevant References of each Project in your Solution. – rskar Apr 12 '16 at 15:49
  • I also did a proof-of-concept of my own, and made it work with AppDomain.CurrentDomain.AssemblyResolve event. So there is a way. – rskar Apr 12 '16 at 15:50

0 Answers0