C# – ‘资源’DLL因为不存在而无法加载 – 如何找到引用以便我可以删除它?

我有一个C#解决方案,它在编译时吐出一个可执行的二进制文件。 二进制文件依赖于一个库,它是我写的另一个解决方案的产物,我创建的所有代码都是有关的。

最近我以一种相当随意的方式玩了很多项目设置,试图了解CLR如何构建链接。 不幸的是(可预见的?)我设法打破了我的二进制文件的链接,但我不知道如何解决这个问题。

  • 当我的二进制文件时,我会在应用程序崩溃之前获得以下反馈

加载程序集……..无法在程序集中添加类型MY.Library,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null – 无法加载一个或多个请求的类型。 检索LoaderExceptions属性以获取更多信息

  • MY.Library.resources DLL的融合日志如下所示。 提到的二进制文件不存在,我不知道它在哪里或为什么要加载。

>

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. 
  • “资源”DLL是隐含的吗? 或者我是否必须引用此DLL? 我应该如何在SLN中找到库的参考?

TL; DR

  • 如何删除对不存在的资源DLL的引用?

  • “资源”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