我如何获得DLL路径 [英] How do I get the DLL path
本文介绍了我如何获得DLL路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
在我的解决方案中,我有三个项目说proj1,proj2,proj3
已经这些都是成功编译的。
现在我在第三个项目时我需要获得第二个项目的dll路径。
我可以用点网做吗。请建议
我尝试过:
尝试使用汇编但没有运气
hi
In my solution I have three projects say proj1,proj2, proj3
already these were compiled sucesfully .
now when I am in 3rd project I need to get the dll path of 2nd project.
can I do it using dot net.please suggest
What I have tried:
tried using Assembly classes but no luck
推荐答案
你需要做的第一件事是确定大会 - 有几种方法可以做到这一点。
如果proj2代码调用proj3中的方法,那么该方法可以使用Assembly.GetCallingAssembly:
The first thing you need to do is identify the Assembly - there are a few ways to do that.
If proj2 code calls a method in proj3, then that method can use Assembly.GetCallingAssembly:
Assembly caller = Assembly.GetCallingAssembly();
如果是不,你可以使用GetAssembly:
If it doesn't, you can use GetAssembly:
Assembly otherProject = Assembly.GetAssembly(typeof(NameOfClassInProj2));
然后你可以使用Location属性:
You can then use the Location property:
string callerPath = caller.Location;
string typePath = otherProject.Location;
这篇关于我如何获得DLL路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文