Created
November 4, 2010 21:53
-
-
Save darrenkopp/663276 to your computer and use it in GitHub Desktop.
resolves assemblies that aren't found
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Resolves the timberline assembly. | |
/// </summary> | |
/// <param name="fileName">Name of the file.</param> | |
/// <returns></returns> | |
private static Assembly ResolveTimberlineAssembly(string fileName) | |
{ | |
var sharedDirectoryKey = Registry.LocalMachine.GetKey("SOFTWARE").GetKey("Timberline").GetKey("General"); | |
if (sharedDirectoryKey != null) | |
{ | |
var sharedDirectory = sharedDirectoryKey.GetValue("Shared Directory") as string; | |
return TryLoadAssembly(Path.Combine(sharedDirectory, fileName)); | |
} | |
return null; | |
} | |
/// <summary> | |
/// Attempts to load an assembly given a file path | |
/// </summary> | |
/// <param name="path">The path.</param> | |
/// <returns>The assembly, if found at the specified path, null if not found</returns> | |
private static Assembly TryLoadAssembly(string path) | |
{ | |
if (File.Exists(path)) | |
{ | |
return Assembly.LoadFrom(path); | |
} | |
return null; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment