简体   繁体   English

使用单独的DLL的类库中缺少DLL

[英]Missing DLLs from a class library that uses separate DLLs

In C# .NET 4.0 I am creating a class library / DLL that I plan to reuse in many other projects. 在C#.NET 4.0中,我正在创建一个计划在许多其他项目中重用的类库/ DLL。 This class library will use several DLLs itself. 该类库本身将使用几个DLL。 For example, the class library I am creating may reference several DLLs like: 例如,我正在创建的类库可能引用多个DLL,例如:

ServerConnectorLibrary references:
Lib1.dll
Lib2.dll
Lib3.dll

When I build this, I get ServerConnectorLibrary.dll as the output in the bin\\Debug folder. 构建此文件时,将得到ServerConnectorLibrary.dll作为bin \\ Debug文件夹中的输出。

What I want now is to use this ServerConnectorLibrary.dll in other projects. 我现在想要的是在其他项目中使用此ServerConnectorLibrary.dll However, when I add the DLL to my new projects and run I get the following error: 但是,当我将DLL添加到新项目中并运行时,出现以下错误:

FileNotFoundException: Could not load file or assembly "Lib1.dll".

If I add Lib1.dll to the bin\\Debug folder of my new project, the problem is not solved. 如果我将Lib1.dll添加到新项目的bin\\Debug文件夹中,则该问题无法解决。

You may be able to combine all of your dependencies into a single assembly. 您可能可以将所有依赖项组合到一个程序集中。 Here is an old example on CodeProject. 这是CodeProject上的一个旧示例。

http://www.codeproject.com/Articles/9364/Merging-NET-assemblies-using-ILMerge http://www.codeproject.com/Articles/9364/Merging-NET-assemblies-using-ILMerge

There is also a StackOverflow thread here... 这里还有一个StackOverflow线程...

How do I merge multiple .net assemblies into a single assembly? 如何将多个.net程序集合并为一个程序集?

Otherwise, make sure the properties for each dependency is set to copy local and then include the dependencies along with your library. 否则,请确保将每个依赖项的属性设置为复制本地,然后将依赖项与库一起包括在内。 These are DLLs, so they are dynamically linked at run-time, unlike older C++ and C libraries that might be statically linked. 这些是DLL,因此它们在运行时是动态链接的,这与可能是静态链接的早期C ++和C库不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM