Ignacio Soler Garcia
Ignacio Soler Garcia

Reputation: 21855

Dependencies referenced by xaml are not loaded from project folder but from executable folder

I have the following simple folder structure:

Root

Root\Executable.exe

Root\Subfolder

Root\Subfolder\Control.dll

Root\Subfolder\ControlDependency.dll

The subfolder has a control based on a 3rd party library. I expected the control to load its dependencies from its own folder but instead it is looking for dependencies in the executable folder.

Is this normal and why it is happening?

Upvotes: 0

Views: 59

Answers (1)

rPulvi
rPulvi

Reputation: 946

When you build the project, all the referenced assemblies will be copied in the output folder and then referenced. The .NET CLR follows these steps to assembly resolving:

  • Examine the Configuration Files
  • Check for Previously Referenced Assemblies
  • Check the Global Assembly Cache
  • Locate the Assembly through Codebases or Probing

If you need to load an assembly at runtime which can be located in any folder (not only the bin folder of the application) you can use one of these three methods:

  • Install the assembly into the Global Assembly Cache (GAC)
  • Use an application configuration (.config) file with the tag.
  • Use the AssemblyResolve event

Please, follow this links to learn more:

Upvotes: 1

Related Questions