Skip to content

Instantly share code, notes, and snippets.

@darrenkopp
Created November 4, 2010 21:53
Show Gist options
  • Save darrenkopp/663276 to your computer and use it in GitHub Desktop.
Save darrenkopp/663276 to your computer and use it in GitHub Desktop.
resolves assemblies that aren't found
/// <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