Udostępnij za pośrednictwem


Partially Qualified Assembly References and Side-by-Side Execution

Because they are a potential source of side-by-side problems, partially qualified assembly references can be used only to bind to assemblies within an application directory. Avoid partially qualified assembly references in your code.

To mitigate partially qualified assembly references in code, you can use the <qualifyAssembly> element in an application configuration file to fully qualify partially qualified assembly references that occur in code. Use the <qualifyAssembly> element to specify only fields that were not set in the partial reference. The assembly identity listed in the fullName attribute must contain all the information needed to fully qualify the assembly name: assembly name, public key, culture, and version.

The following example shows the application configuration file entry to fully qualify an assembly called myAssembly.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
<qualifyAssembly partialName="myAssembly" 
fullName="myAssembly,
      version=1.0.0.0, 
publicKeyToken=..., 
      culture=neutral"/> 
</assemblyBinding> 

Whenever an assembly load statement references myAssembly, these configuration file settings cause the runtime to automatically translate the partially qualified myAssembly reference to a fully qualified reference. For example, Assembly.Load("myAssembly") becomes Assembly.Load("myAssembly, version=1.0.0.0, publicKeyToken=..., culture=neutral").

Note

You can use the LoadWithPartialName method to bypass the common language runtime restriction that prohibits partially referenced assemblies from being loaded from the global assembly cache. This method should be used only in remoting scenarios as it can easily cause problems in side-by-side execution.

See Also

Concepts

Assembly Names

Other Resources

Assemblies in the Common Language Runtime

Side-by-Side Execution Fundamentals