-イベントを処理しAssemblyResolve
ましたが、まだFileNotFoundException
. 型初期化子でイベントをサブスクライブし、 -methodAssembly.LoadFrom
でメソッドを呼び出します。Main
class Program
{
static Program()
{
AppDomain.CurrentDomain.AssemblyResolve+=new ResolveEventHandler(DeployAssemblyHandler);
}
static void Main(string[] args)
{
try
{
System.Reflection.Assembly asm=Assembly.LoadFrom("AxInterop.SHDocVw.dll");
}
catch(Exception)
{
}
}
public static System.Reflection.Assembly DeployAssemblyHandler(object sender,ResolveEventArgs args)
{
Assembly asm = null;
string asmName = new AssemblyName(args.Name).Name;
string deployAssemblyDirPath = ""; // Common.AppUtil.InstallDir + AppUtil.DeployedAssemblyDir;
string[] deployDirectories = Directory.GetDirectories(deployAssemblyDirPath);
foreach(string deploy in deployDirectories)
{
try
{
asm = Assembly.LoadFrom(deploy + "\\" + asmName);
break;
}
catch (Exception ex) { }
}
return asm;
}
}