How to load project references from a sub directory in C# and VB.NET

To load project references from a sub directory in C# and VB.NET you simply need to add the element to your app.config file.

  • assemblyBinding: Contains information about assembly version redirection and the locations of assemblies.
  • configuration: The root element in every configuration file used by the common language runtime and .NET Framework applications.
  • runtime: Contains information about assembly binding and garbage collection.
  • Sample XML

    <configuration>
       <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
             <probing privatePath="bin;bin2\subbin;bin3"/>
          </assemblyBinding>
       </runtime>
    </configuration>
    

    How to get the path of the active app.config file in C# and VB.NET

    To get the path of the active app.config file in C# and VB.NET you can use the following snippet

    Sample C#

    AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
    

    Sample VB.NET

    AppDomain.CurrentDomain.SetupInformation.ConfigurationFile