C# - 'Resources' DLL 加载失败,因为它不存在 - 如何找到引用以便删除它?



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

最近,我以一种相当随意的方式摆弄了一些项目设置,试图感受一下CLR如何构建链接。不幸的是(可以吗?)我已经设法打破了我的二进制链接,但我不知道如何解决这个问题。

  • 当我的二进制文件,我得到以下反馈之前,应用程序下降

加载程序集……不可能在程序集中添加类型我的。图书馆,Version = 1.0.0.0,文化=中性,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:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll Running under executable  G:SVNdevDebugMYExecutable.exe
--- A detailed error log follows. 
=== Pre-bind state information === LOG: User = UBERITgavina 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:BuildSVNappsExecSysMYExecutabledevDebugMYExecutable.exe.Config LOG: Using host configuration file:  LOG: Using machine configuration file from C:WindowsMicrosoft.NETFramework64v4.0.30319configmachine.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的引用吗?我该如何在图书馆的参考文献编号中找到参考资料?

TL,博士

  • 如何删除对不存在的资源DLL的引用?
  • "资源"dll是隐式的吗?或者我一定要参考这个DLL吗?我该如何在图书馆的参考文献编号中找到参考资料?
  • 如何删除对不存在的资源DLL的引用?

资源实际上嵌入在dll中。你不需要引用它。
你看到"图书馆"的原因。是因为你的代码要求。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。事实证明(最后)这是我移动主窗口的结果。Xaml到子文件夹。我不知道它是否与windows窗体相同,但对于WPF的任何人:不要移动MainWindow.xaml。又浪费了一天的生命。

通常你引用的dll应该在你的c#项目的References文件夹中(你也应该从那里添加你的外部dll)。您可以右键单击要踢出的DLL,然后单击Remove