Search code examples
c#pathapp-configprivateprobing

C# Set probing privatePath without app.config?


I have a C# application, and to organize its files I have some DLL's in a folder called "Data". I want the EXE to check this folder for the DLL's just like how it checks its current directory. If I created a App.Config with this information:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="Data" />
    </assemblyBinding>
  </runtime>
</configuration>

It works without a problem. I do not want to have an App.Config. Is there a way to set the probing path without using an app.config?


Solution

  • You can do it for new AppDomains you create, I don't believe there is a way to do it in managed code for current/default AppDomain.

    Edit: Creating AppDomain with private path: use AppDomain.CreateDomain and AppDomainSetup.PrivateBinPath