C#:如何包含依赖DLL? [英] C#: How to include dependent DLLs?

查看:520
本文介绍了C#:如何包含依赖DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用在2个DLL中定义的第三方API。我将这些DLL包含在我的项目中,并设置了对它们的引用。到现在为止还挺好。

I am using a 3rd party API which is defined in 2 DLLs. I have included those DLLs in my project and set references to them. So far so good.

但是,这些DLL至少有一个在运行时无法找到的依赖DLL。我将丢失的DLL复制到项目中并设置复制到输出标志,但没有成功。

However, these DLLs have at least one dependent DLL which cannot be found at runtime. I copied the missing DLL into the project and set the 'Copy to output' flag but without success.

我应该在这里做什么来告诉项目哪里应该找到依赖的DLL?

What should I be doing here to tell the project where it should find the dependent DLL?

澄清
我尝试添加对缺少的DLL的引用,但不被识别为。网络组件。在绝望中,我将它直接添加到输出文件夹,但没有成功。

Clarification I tried adding a reference to the missing DLL but as it wasn't recognised as a .Net component. In desperation, I added it directly to the output folder but without success.

最后,我在PC上安装了API,一切正常。安装将设置PATH变量,并在安装文件夹中找到该DLL。

Finally, I installed the API on the PC and it all worked. The installation sets the PATH variable and the DLL is found in the installation folder. But how to tell the project to look in one of its internal folders?

推荐答案

这听起来像是您需要更好地了解第三方库,以及它如何使用自己的依赖关系。如果安装API解决了问题,但是手动复制文件没有,那么你会丢失一些东西。有一个缺少的文件或一些需要的环境变量或注册表项。两件事情真的可以帮助你,这是依赖工具(它是C ++安装的一部分)和procmon,它将告诉你运行时使用的所有注册表项和文件。

It sounds like you need to better understand the third-party library and how it uses its own dependencies. If the installation of the API solves the problem, but copying the files manually does not, then you're missing something. There's either a missing file, or some environment variable or registry entry that's required. Two things that will really help you in this is the depends tool (which is part of the C++ installation) and procmon, which will tell you all the registry keys and files that get used at runtime.

如果你幸运,那只是一个你缺少的文件。如果是这样,您可以使用项目的构建事件部分将所需的文件复制到成功构建的正确位置。如果没有,您将不得不以其他方式解决这个问题 - 要么安装API,要么滚动自己的安装项目。

If you're lucky, it's just a file that you're missing. If that's all it is, you can use the "Build Events" section of the project to copy the needed files to the right location on a successful build. If not, you're going to have to solve this some other way - either by requiring the API be installed, or rolling your own installation project.

这篇关于C#:如何包含依赖DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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