[英]C# - 'Resources' DLL failing to be loaded as it doesn't exist - How might I find the reference so that I can remove it?
我有一個C#解決方案,它在編譯時吐出一個可執行的二進制文件。 二進制文件依賴於一個庫,它是我寫的另一個解決方案的產物,我創建的所有代碼都是有關的。
最近我以一種相當隨意的方式玩了很多項目設置,試圖了解CLR如何構建鏈接。 不幸的是(可預見的?)我設法打破了我的二進制文件的鏈接,但我不知道如何解決這個問題。
加載程序集........無法在程序集中添加類型MY.Library,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null - 無法加載一個或多個請求的類型。 檢索LoaderExceptions屬性以獲取更多信息
>
All probing URLs attempted and failed
*** Assembly Binder Log Entry (22/04/2011 @ 10:34:17) ***
The operation failed. Bind result: hr
= 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under executable G:\SVN\dev\Debug\MYExecutable.exe
--- A detailed error log follows.
=== Pre-bind state information === LOG: User = UBERIT\gavina LOG: DisplayName = MY.Library.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null (Fully-specified) LOG: Appbase = file:///G:/SVN/dev/Debug LOG: Initial PrivatePath = x64 LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = MYExecutable.exe Calling assembly : MY.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
=== LOG: This bind starts in default load context.
LOG: Using application configuration file: G:\BuildSVN\apps\ExecSys\MYExecutable\dev\Debug\MYExecutable.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///G:/SVN/dev/Debug/en/MY.Library.resources.DLL.
LOG: Attempting download of new URL file:///G:/SVN/dev/Debug/en/MY.Library.resources/MY.Library.resources.DLL.
LOG: Attempting download of new URL file:///G:/SVN/dev/Debug/x64/en/MY.Library.resources.DLL.
LOG: Attempting download of new URL file:///G:/SVN/dev/Debug/x64/en/MY.Library.resources/MY.Library.resources.DLL.
LOG: Attempting download of new URL file:///G:/SVN/dev/Debug/en/MY.Library.resources.EXE. LOG: Attempting download of new URL file:///G:/SVN/dev/Debug/en/MY.Library.resources/MY.Library.resources.EXE.
LOG: Attempting download of new URL file:///G:/SVN/dev/Debug/x64/en/MY.Library.resources.EXE.
LOG: Attempting download of new URL file:///G:/SVN/dev/Debug/x64/en/MY.Library.resources/MY.Library.resources.EXE.
LOG: All probing URLs attempted and failed.
TL; DR
- “資源”DLL是隱含的嗎? 或者我是否必須引用此DLL? 我應該如何在SLN中找到庫的參考?
- 如何刪除對不存在的資源DLL的引用?
資源實際上嵌入了你的dll。 您無需參考它。
您看到“library.resouce”的原因是因為您的代碼要求.net手動加載程序集,無論是app.config還是AppDomain.AssemblyResolve事件。
在你的情況下,我認為這是后者。 只需找到該事件處理程序並執行以下操作:
static System::Reflection::Assembly^ HandleAssemblyResolveEvent(System::Object^ sender, System::ResolveEventArgs^ args)
{
System::String^ assemblyName = args->Name->Substring(0, args->Name->IndexOf(","));
if(assemblyName->EndsWith(".resources")) return nullptr;
}
代碼在C ++ \\ CLI中,但很容易轉換為C#。
我剛遇到這樣的問題,visual studio 2010找不到各種資源dll,比如xaml.resources.dll和presentationcore.resources.dll。 結果(最后)是我將MainWindow.xaml移動到子文件夾的結果。 我不知道它是否與Windows窗體相同,但對於那些做WPF的人:不要移動MainWindow.xaml。 我生命中的另一天浪費了。
通常,您引用的DLL應該位於C#項目的References
文件夾中(您也應該從那里添加外部DLL)。 您可以右鍵單擊要踢出的DLL,然后單擊“ Remove
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.