2012-02-15 17 views
1

我添加了一个DLL“first.dll”在我的C#项目引用这又使用另一个传统DLL“second.dll”对DLL如何给别名在C#

的“first.dll”预期“second.dll”位于同一文件夹中。如果我将“second.dll”移动到另一个文件夹,那么“first.dll”会给出错误。

有没有一种方法可以在我的应用程序中定义“second.dll”路径?

我无权访问这两个DLL的源代码。

+1

这是遗留代码? – IanNorton 2012-02-15 10:11:26

+0

查看是否为这两个dll引用设置了“复制到输出,如果更新” – sll 2012-02-15 10:12:19

+0

默认情况下,.Net希望在GAC或相同的文件夹中查找它的依赖程序集的exe文件。您是否可以将您的项目设置为“复制到输出目录”以用于这两个dll? – IanNorton 2012-02-15 10:13:30

回答

0

我解决它通过挑选基于需要什么程序的DLL。一个简单的IF条件的窍门。

1

你可以尝试在你的应用程序配置使用<codebase>(假设second.dll是.NET程序集)

来自实例链接的文章:

<configuration> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
      <assemblyIdentity name="myAssembly" 
          publicKeyToken="32ab4ba45e0a69a1" 
          culture="neutral" /> 
      <codeBase version="2.0.0.0" 
        href="http://www.litwareinc.com/myAssembly.dll"/> 
     </dependentAssembly> 
    </assemblyBinding> 
</runtime>