我有一个 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 是隐式的吗?或者我一定要参考一下
这个DLL?我应该如何在 SLN 中找到该库的参考文献?
- 如何删除对不存在的资源 DLL 的引用?
资源实际上嵌入在您的 dll 中。你不需要引用它。
您看到“library.resouce”的原因是因为您的代码要求 .net 手动加载程序集,尽管如此应用程序配置 http://msdn.microsoft.com/en-us/library/4191fzwb.aspx, or AppDomain.AssemblyResolve http://msdn.microsoft.com/en-us/library/ff527268.aspx事件。
就你的情况而言,我认为是后者。只需找到该事件处理程序并执行如下操作:
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#。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)