[英]How do you tell which dll your c# application is using?
I have an application which uses a .dll which is full of gui application code in location x. 我有一个使用.dll的应用程序,它在位置x中充满了gui应用程序代码。 It use to have 1 button in, but now has 2. 它用来有1个按钮,但现在有2个。
When i start my application what i expect to see is a gui with 2 buttons, however i see a gui with 1 button. 当我启动我的应用程序时,我期望看到的是一个带有2个按钮的gui,但是我看到一个带有1个按钮的gui。 i have rebuild my gui .dll but it is magically using an older version from somewhere. 我重建了我的gui .dll,但它神奇地使用了某个地方的旧版本。 If i try and debug my code it says that the version of code i am using is different from the one in the .dll 如果我尝试调试我的代码,它说我使用的代码版本与.dll中的代码版本不同
My question is, "How can i find out where it is looking for the .dll and why would it be using an old version as i only have 1 place where i compile the .dll to?" 我的问题是,“我如何才能找到它在哪里寻找.dll以及为什么它会使用旧版本,因为我只有一个地方可以将.dll编译成?”
Also wanted to state that i have it referenced and it is the correct version which has the 2 buttons in.. but when i run it is using another version??? 还想说明我已经引用它,它是正确的版本,其中有2个按钮..但是当我运行它是使用另一个版本???
If you are using Visual Studio open the Modules window, Debug->Windows->Modules (Ctrl-D+M) and this will list all loaded assemblies. 如果您使用的是Visual Studio,请打开“模块”窗口,调试 - > Windows->模块(Ctrl-D + M),这将列出所有已加载的程序集。
You can also at run time use AppDomain.CurrentDomain.GetAssemblies() and walk the list looking at each Assembly.CodeBase. 您还可以在运行时使用AppDomain.CurrentDomain.GetAssemblies()并查看每个Assembly.CodeBase的列表。
If all else fails you can also use ProcessMonitor from sysinternals http://technet.microsoft.com/en-us/sysinternals/bb896645 and watch which dlls are loaded by your process, but you'll be filtering out tons of output. 如果所有其他方法都失败了,您也可以使用sysinternals中的ProcessMonitor http://technet.microsoft.com/en-us/sysinternals/bb896645并查看您的进程加载了哪些dll,但是您将过滤掉大量的输出。
If you are debugging you can open the Modules window ( Debug > Windows > Modules ). 如果您正在调试,可以打开“ 模块”窗口(“ 调试” >“ Windows” >“ 模块” )。 This will show you all the executable files loaded into your process including the name and full path. 这将显示加载到您的进程中的所有可执行文件,包括名称和完整路径。 You should then be able to figure out from where an out-of-date DLL was loaded. 然后,您应该能够找出加载了过时DLL的位置。
You could try using Reflection in the System.Reflection
namespace: 您可以尝试在System.Reflection
命名空间中使用Reflection :
var assembly = Assembly.Load("your-assembly-name");
And then examine the assembly
object for version info. 然后检查assembly
对象的版本信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.