How SmartAssembly searches for dependencies
Published 31 December 2012
To locate and load a dependency, SmartAssembly searches for the dependency in the following locations, in this order:
- The GAC (Global Assembly Cache). The dependency must have an assembly name which includes the same version number and public key token.
- The framework folder and associated folders (for SDKs, Silverlight, XNA, etc.).
- The main assembly folder for a dependency with a similar assembly name (even if the version and/or public key token are different).
If your dependency is not found, or if the wrong version of it is found, you can override the normal behavior by manually editing the SmartAssembly project file (*.saproj) in an XML editor. To do this, add the MandatoryPath
attribute to the <
Assembly>
tag, as in the example below:
<Assembly AssemblyName="dependency_assembly_name" MandatoryPath="C:\path\DependencyToUse.dll"> ... </Assembly>
SmartAssembly will always use the dependency found at this location.
If the dependency is not valid (for example, the file is not found, or the assembly has a different assembly name), SmartAssembly does not process your assembly and reports an error.
Removing folders from the dependency search
In rare cases, you may wish to ignore a folder when SmartAssembly searches for a dependency. An example is when you do not have permission to access the folder, and so you cannot check which versions of the dependency are in the folder.
To remove a folder from the dependency search:
- In an XML editor, open the SmartAssembly.settings file.
- In Windows Vista and later, this is stored in %ProgramData%\Red Gate\SmartAssembly\
- In Windows XP, this is stored in %ProgramFiles%\Red Gate\SmartAssembly 6\
- In Windows Vista and later, this is stored in %ProgramData%\Red Gate\SmartAssembly\
- Find the
<
DependenciesSearchPaths>
node. - In the
<
DependenciesSearchPaths>
, each search path is contained in a<
SearchPath>
node. - Delete the search path that you do not want to look in when SmartAssembly searches for dependencies.