C# - “资源” DLL 无法加载,因为它不存在 - 我如何找到引用以便将其删除?

发布于 2024-11-02 21:09:10 字数 2740 浏览 0 评论 0 原文

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

最近,我以相当随意的方式尝试了一些项目设置,试图了解 CLR 构建链接的工作原理。不幸的是(可以预见?)我已经设法破坏了二进制文件上的链接,但我不确定如何解决该问题。

  • 当我的二进制文件在应用程序失败之前我收到以下反馈

正在加载程序集......无法 在程序集中添加类型 MY.Library,版本=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:\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 的引用?

I have a C# Solution which spits out an executable binary on compilation. The binary depends on a library which is the product of another solution which I wrote, all code concerned I created.

Recently I played around with a number of project settings in a fairly haphazard manner, trying to get a feel for how CLR building an linking works. Unfortunately (predictably?) I have managed to break the linking on my binary but I'm not sure how to fix the issue.

  • When I my binary I get the following feedback before the application falls over

Loading assemblies........Could not
add types in assembly
MY.Library, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null -
Unable to load one or more of the
requested types. Retrieve the
LoaderExceptions property for more
information

  • The fusion log for the MY.Library.resources DLL is below. The mentioned binary doesn't exist and I don't know where or why it's trying to be loaded.

>

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.
  • Are 'Resources' DLLs Implicit? Or do I necessarily have a reference to this DLL? How should I find the reference in the SLN for the library?

TL;DR

  • How do I remove a reference to a non-existant resources DLL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

深海里的那抹蓝 2024-11-09 21:09:10
  • “资源”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#。

  • Are 'Resources' DLLs Implicit? Or do I necessarily have a reference to
    this DLL? How should I find the reference in the SLN for the library?
  • How do I remove a reference to a non-existant resources DLL?

The resouces is actually embedded in your dll. You don't need to reference it.
The reason you see "library.resouce" is because your code asks .net to load assembly manually, either though app.config, or AppDomain.AssemblyResolve event.

In your case, I think it's the latter. Just find that event handler and do something like this:

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;
}

The code is in C++\CLI but it's easy to translate to C#.

回首观望 2024-11-09 21:09:10

我刚刚遇到了这样的问题,Visual Studio 2010无法找到各种资源DLL,例如xaml.resources.dll和presentationcore.resources.dll。事实证明(最终)这是我将 MainWindow.xaml 移动到子文件夹的结果。我不知道它是否与 Windows 窗体相同,但对于任何使用 WPF 的人来说:请勿移动 MainWindow.xaml。我生命中的又一天被浪费了。

I just had a problem like that, visual studio 2010 couldn't find all kinds of resources dlls, like xaml.resources.dll and presentationcore.resources.dll. Turns out (in the end) it was the result of me moving the MainWindow.xaml to a subfolder. I don't know if it's the same with windows forms, but to anyone out there doing WPF: DO NOT MOVE MainWindow.xaml. Another day of my life wasted.

假扮的天使 2024-11-09 21:09:10

通常,您引用的 DLL 应该位于 C# 项目的 References 文件夹中(您还应该从那里添加外部 DLL)。您可以右键单击要踢出的 DLL,然后单击删除

Normally your referenced DLLs should be in the References folder in your C# project (you should also add your external DLLs from there too). You can right-click the DLL you want to kick out and click Remove.

奶茶白久 2024-11-09 21:09:10

对我来说它可以修复 Visual Studio

For me it worked repairing the Visual Studio

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文