如何确定 .NET 应用程序的依赖项? [英] How do I determine the dependencies of a .NET application?

查看:24
本文介绍了如何确定 .NET 应用程序的依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定 .NET 应用程序的依赖项?Dependency Walker 是否适用于托管应用?我已经下载了最新的并尝试分析该应用程序,但它只是退出而没有太多解释.如果它不适用于 .NET,那么是否有其他工具可以帮助我调试运行时 DLL 加载问题?

解决方案

Dependency walker 适用于普通的 win32 二进制文件.所有 .NET dll 和 exe 都有一个小的存根头部分,这使它们看起来像普通的二进制文件,但它基本上说的是加载 CLR"——这就是依赖遍历器会告诉你的全部内容.

要查看您的 .NET 应用程序实际依赖哪些内容,您可以使用非常出色的 .NET 反射器来自 Red Gate.(请注意,.NET Reflector 现在是付费产品.ILSpy 是免费和开源的,非常相似.)

将您的 DLL 加载到其中,右键单击并选择分析" - 然后您将看到一个取决于"项目,该项目将向您显示它需要的所有其他 dll(以及这些 dll 中的方法).

虽然有时会变得更棘手,因为您的应用程序依赖于 X dll,并且存在 X dll,但由于某种原因无法在运行时加载或定位.

为了解决这些类型的问题,Microsoft 有一个 Assembly绑定日志查看器,它可以向您显示运行时

How do I determine the dependencies of a .NET application? Does Dependency Walker work with managed apps? I've downloaded the latest and tried profiling the app, but it just exits without much of an explanation. If it doesn't work with .NET, then is there some other tool that would help me debug a run-time DLL loading issue?

解决方案

Dependency walker works on normal win32 binaries. All .NET dll's and exe's have a small stub header part which makes them look like normal binaries, but all it basically says is "load the CLR" - so that's all that dependency walker will tell you.

To see which things your .NET app actually relies on, you can use the tremendously excellent .NET reflector from Red Gate. (EDIT: Note that .NET Reflector is now a paid product. ILSpy is free and open source and very similar.)

Load your DLL into it, right click, and chose 'Analyze' - you'll then see a "Depends On" item which will show you all the other dll's (and methods inside those dll's) that it needs.

It can sometimes get trickier though, in that your app depends on X dll, and X dll is present, but for whatever reason can't be loaded or located at runtime.

To troubleshoot those kinds of issues, Microsoft have an Assembly Binding Log Viewer which can show you what's going on at runtime

这篇关于如何确定 .NET 应用程序的依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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