我有一个C#解决方案,它在编译时吐出一个可执行的二进制文件。二进制文件依赖于一个库,它是我写的另一个解决方案的产物,我创建的所有代码都是有关的。
最近,我以一种相当随意的方式玩弄了许多项目设置,试图了解CLR如何构建链接。不幸的是(可以预见?)我设法打破了我的二进制文件的链接,但我不确定如何解决这个问题。
装载组件........不能 在程序集中添加类型 MY.Library,版本= 1.0.0.0, Culture = neutral,PublicKeyToken = null - 无法加载一个或多个 要求的类型。检索 LoaderExceptions属性更多 信息
>
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.
TL; DR
答案 0 :(得分:3)
- '资源'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#。
答案 1 :(得分:1)
我遇到了类似的问题,visual studio 2010找不到各种资源dll,比如xaml.resources.dll和presentationcore.resources.dll。结果(最后)是我将MainWindow.xaml移动到子文件夹的结果。我不知道它是否与Windows窗体相同,但对于那些做WPF的人:不要移动MainWindow.xaml。我生命中的另一天浪费了。
答案 2 :(得分:0)
通常,您引用的DLL应该位于C#项目的References
文件夹中(您还应该从那里添加外部DLL)。您可以右键单击要踢出的DLL,然后单击Remove
。