如何从托管DLL获取可执行路径 [英] How to get the executable path from a Managed DLL
本文介绍了如何从托管DLL获取可执行路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个托管的DLL(用C ++ / CLI编写),它包含一个由C#可执行文件使用的类。在类的构造函数中,我需要访问引用DLL的可执行文件的完整路径。在实际的应用程序中,我知道我可以使用Application对象来做这件事,但是如何从托管的DLL呢?
解决方案
pre> Assembly.GetCallingAssembly()
或
Assembly.GetExecutingAssembly()
$ b b
或
Assembly.GetEntryAssembly()
根据需要。
然后使用Location或CodeBase属性>
I have a managed DLL (written in C++/CLI) that contains a class used by a C# executable. In the constructor of the class, I need to get access to the full path of the executable referencing the DLL. In the actual app I know I can use the Application object to do this, but how can I do it from a managed DLL?
解决方案
Assembly.GetCallingAssembly()
or
Assembly.GetExecutingAssembly()
or
Assembly.GetEntryAssembly()
Depending on your need.
Then use Location or CodeBase property (I never remember which one).
这篇关于如何从托管DLL获取可执行路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文