Question Resolving assemblies at runtime

rhoaste

Member
Joined
Jun 16, 2010
Messages
19
Programming Experience
10+
My objective is to ensure that during my application initialisation, the installed assembly versions are correct and compatible with my application references. I would like to do this check to make the application fail "gracefully" as opposed to generating an unhandled exception. I'm also trying to make this check as generic as possible so I can incorporate it in future applications. I regularly write applications that involve reference to stand-alone DLLs, and 3rd party tools.

After getting a list of referenced assemblies from reflection, I loop through and attempt to perform:
VB.NET:
objAssembly = Assembly.Load(objAssemblyName)
If the load fails, I try this:
VB.NET:
objAssembly = Assembly.Load(AssemblyName.GetAssemblyName(objAssemblyName.Name & ".dll"))

I've recently read that this approach is similar to the depreciated method Assembly.LoadWithPartialName, and this is not recommended due to ambiguity.

So, what I would like to do is exactly what the runtime does to resolve all assemblies. After reading the MSDN documentation on "how the runtime locates assemblies" and "best practices for Assembly loading", I'm none the better off for understanding how achieve this programmatically.

Kind regards.
 
Back
Top