事實證明,我正在過問這個問題。
在我的WPF DLL中,我有一個使用開源Web瀏覽器控件的自定義控件類。
在自定義控件的靜態構造函數中,我爲AppDomain.CurrentDomain.AssemblyResolve
事件設置了一個處理函數。
而對我的處理程序:
private static Assembly Resolver(object sender, ResolveEventArgs args)
{
if(args.Name.StartsWith("CefSharp"))
{
string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "CefSharp", Environment.Is64BitProcess ? "x64" : "x86", assemblyName);
return File.Exists(archSpecificPath) ? Assembly.LoadFile(archSpecificPath) : null;
}
return null;
}
在處理我檢查,看是否有CefSharp組件被解決,如果是的話,我創建基於正確裝配的路徑,如果我的組件運行在一個64位的過程中,然後做一個Assembly.LoadFile()
。
我希望這有幫助!
我的問題是,你甚至有嗎?你可以添加你的DLL項目作爲你的EXE項目中的一個參考,併爲第三方DLL做動態程序集解析,它會正常工作嗎?你有沒有嘗試過?任何錯誤? – Zack
或者你可能不得不建立你的DLL項目爲x86和x64,並動態加載它......我沒有太多的動態分辨率的經驗,所以我可能會離開,只是想辦法解決。 – Zack
嘗試http://stackoverflow.com/questions/108971/using-side-by-side-assemblies-to-load-the-x64-or-x32-version-of-a-dll/156024#156024和http: //stackoverflow.com/questions/2963809/anycpu-x86-x64-for-c-sharp-application-and-its-c-cli-dependency – neohope