确定哪些DLL使用的C#程序文件的列表 [英] Determine the list of files which DLL uses in C# program

查看:218
本文介绍了确定哪些DLL使用的C#程序文件的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会尽力来形容我的问题......我加载,例如,使用General.dll在我的项目(​​C#)

I will try to describe my question... I load, for example, "General.dll" in my project (C#) using

//load "General.dll"
dllHandle = LoadLibraryEx(generalPath, IntPtr.Zero, LOAD_WITH_ALTERED_SEARCH_PATH);

[DllImport("kernel32.dll")]         
private static extern IntPtr LoadLibraryEx(string dllToLoad, IntPtr reserved, uint flags);

[DllImport("General.dll")] ...

如果我使用的方法从General.dll要求Gif.dll我需要复制Gif.dll与General.dll的文件夹(如果我不使用这样的方法我可以做不可复制Gif.dll)。

If I use a method from "General.dll" which requires "Gif.dll" I need to copy "Gif.dll" to the folder with "General.dll" (if I do not use such method I can do not copy "Gif.dll").

如果我使用的方法从General.dll,它采用荷兰的语言,我需要复制Dutch.amd的文件夹General.dll。

If I use a method from"General.dll" which uses "Dutch" language, I need to copy "Dutch.amd" to the folder with "General.dll".

例如,我已经写了一些code,它使用从General.dll不同的方法。如何确定从具有General.dll的文件夹中哪些文件,我可以删除吗?

For example, I have wrote some code which uses different methods from "General.dll". How to determine which files from the folder with "General.dll" I can delete?

我能做到这一点使用Visual Studio?例如,编译我的code在VS,找出哪些文件,运行过程中使用,并且只复制这些文件。

Can I do this using Visual Studio? For example, compile my code in VS, find out which files were used during runtime and copy only these files.

谢谢!

推荐答案

通常情况下,任何可再发行组件将包括国家部署指南哪些文件必须部署,在那里他们必须部署到,而且必须发生的任何登记。我强烈建议您查看 general.dll 的文件,如果存在的话。

Typically, any redistributable component will include deployment guidelines which state what files must be deployed, where they must be deployed to, and any registration that must occur. I highly recommend you review the documentation for general.dll, if it exists.

如果 general.dll 是你自己的工作,再看看code查找所有引用的文件和程序集。如果实在是太庞大,一个体面的启发可能是运行进程监视器同时采用了组件监视文件和注册表访问。许多安装程序制作工具使用类似的技术来检测依赖关系。

If general.dll is your own work, then look at the code to find all referenced files and assemblies. If it is too voluminous, a decent heuristic might be to run Process Monitor while using the component to monitor file and registry access. Many installer authoring tools use similar techniques to detect dependencies.

如果您还没有文档和源$ C ​​$ C有问题的部件,您可以使用 DUMPBIN /家属 的Dependency Walker /的 带的Depends.exe ,甚至只是 字符串 找声明的进口。但是要小心,这个名单是不是排他性的,并且可能留下了加载条件的重要文件(仅在某些机型,文化,或以其他方式)。

If you do not have documentation nor source code for the component in question, you can use dumpbin /dependents, Dependency Walker / depends.exe, or even just strings to find the imports declared. Beware, however, that this list is not exclusive, and may leave out critical files loaded conditionally (only on certain machine types, cultures, or otherwise).

这篇关于确定哪些DLL使用的C#程序文件的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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