C# - “资源”DLL失败,因为它不存在加载 - 我怎么可能会发现参考,这样我可以删除吗? [英] C# - 'Resources' DLL failing to be loaded as it doesn't exist - How might I find the reference so that I can remove it?

查看:224
本文介绍了C# - “资源”DLL失败,因为它不存在加载 - 我怎么可能会发现参考,这样我可以删除吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



最近我在一个相当大的偶然性方式的一些项目设置发挥各地,试图获得CLR如何建立一个链接的作品的感觉。不幸的是(可预测?)我已成功地打破我的二进制文件的链接,但我不知道如何解决这个问题。




  • 在当前我在我的二进制我得到以下反馈申请属于过




装载程序集之前..... ...无法
添加类型组装
MY.Library,版本= 1.0.0.0,
区域性=中性公钥=空 -
无法加载一个或多个在
要求的类型。检索更多
信息



LoaderExceptions财产


  • 融合日志中MY.Library.resources DLL是以下。上面提到的二进制文件不存在,我不知道在哪里,或者为什么它试图加载。



>



 所有探测网址企图失败

***大会粘结剂日志条目(22/04/2011 @ 10: 34:17)***

操作失败。绑定结果:HR
= 0x80070002。该系统找不到指定的文件。 C::

大会经理从加载\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll下的可执行文件运行摹:\SVN\dev\Debug \MYExecutable.exe
---详细的错误日志如下。

===预绑定状态信息===日志:用户= UBERIT\gavina日志:显示名称= MY.Library.resources,版本= 1.0.0.0,文化= EN公钥=空(完全指定的)日志:应用平台=文件:/// G:/ SVN的/ dev /调试日志:初始PrivatePath = 64 LOG:动态基= NULL日志:缓存基= NULL LOG:AppName的= MYExecutable.exe调用汇编: MY.Library,版本= 1.0.0.0,文化=中立,公钥=空。
===日志:此绑定的默认加载上下文开始。
日志:使用应用程序配置文件:G:\BuildSVN\apps\ExecSys\MYExecutable\dev\Debug\MYExecutable.exe.Config日志:使用主机配置文件:日志:正在使用的机器配置从C文件:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config。
日志:没有被应用政策在这个时候(私人,自定义,局部的,或基于位置的程序集绑定)来引用。日志:新的URL文件试图下载:/// G:/SVN/dev/Debug/en/MY.Library.resources.DLL。
日志:尝试新的URL文件下载:/// G:/SVN/dev/Debug/en/MY.Library.resources/MY.Library.resources.DLL。
日志:尝试新的URL文件下载:/// G:/SVN/dev/Debug/x64/en/MY.Library.resources.DLL。
日志:尝试新的URL文件下载:/// G:/SVN/dev/Debug/x64/en/MY.Library.resources/MY.Library.resources.DLL。
日志:尝试新的URL文件下载:/// G:/SVN/dev/Debug/en/MY.Library.resources.EXE。日志:新的URL文件试图下载:/// G:/SVN/dev/Debug/en/MY.Library.resources/MY.Library.resources.EXE。
日志:尝试新的URL文件下载:/// G:/SVN/dev/Debug/x64/en/MY.Library.resources.EXE。
日志:尝试新的URL文件下载:/// G:/SVN/dev/Debug/x64/en/MY.Library.resources/MY.Library.resources.EXE。
日志:所有探测网址企图失败了。




  • 是'资源'的DLL隐?或者我一定要这个DLL的引用?我应该如何找到该库中的SLN参考



TL; DR




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


解决方案


  • 是'资源'的DLL隐?或者我一定要$ B $的参考B这个DLL吗?我应该如何找到在SLN为图书馆参考?

  • 我如何删除引用一个不存在的资源DLL?




resouces实际上是嵌入在你的DLL。你并不需要参考其结果
你看library.resouce的原因是因为你的代码要求.NET手动集加载,或者虽然的app.config AppDomain.AssemblyResolve 事件。



在你的情况,我认为是后者。只要找到该事件处理程序,并做这样的事情:

 静态系统::思考::大会^ HandleAssemblyResolveEvent(系统:对象^发件人,系统:: ResolveEventArgs ^参数)
{
系统:字符串^ =的AssemblyName&args- GT;名称 - >的子串(0,args->名称 - >的IndexOf( ));
如果(assemblyName->的endsWith(资源))返回nullptr;
}



中的代码是在C ++ \CLI但很容易转换为C#。


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?

解决方案

  • 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#.

这篇关于C# - “资源”DLL失败,因为它不存在加载 - 我怎么可能会发现参考,这样我可以删除吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆