How do I find the specific path where a DLL was loaded from?
April 8, 2011 1:13 PM Subscribe
Programming Filter: How do I find the specific path where a DLL was loaded from?
Let's say I have a VB.NET program that has a reference to Library.DLL. When the program runs, I want to show a message box that displays the exact path where the program load the DLL from. Is that possible?
I'm basically trying to build a testing utility that tells me where various libraries are being loaded from.
Let's say I have a VB.NET program that has a reference to Library.DLL. When the program runs, I want to show a message box that displays the exact path where the program load the DLL from. Is that possible?
I'm basically trying to build a testing utility that tells me where various libraries are being loaded from.
Response by poster: Thanks! That worked perfectly! I'm posting the VB.NET code below, in case anyone ever needs it!
Dim assemblies = AppDomain.CurrentDomain.GetAssemblies()
For Each assembly As Reflection.Assembly In assemblies
MsgBox(assembly.Location)
Next
posted by JPowers at 1:34 PM on April 8, 2011
Dim assemblies = AppDomain.CurrentDomain.GetAssemblies()
For Each assembly As Reflection.Assembly In assemblies
MsgBox(assembly.Location)
Next
posted by JPowers at 1:34 PM on April 8, 2011
Is there an equivalent of GetModuleHandle and GetModuleFileName in vb.net?
On preview, you solved the issue. The approach implied by the functions above works in C/C++/assembly. And I have another, even cooler approach, that works entirely by reading the Process Execution Block and walking the loaded modules. In assembly, no less.
posted by Netzapper at 1:36 PM on April 8, 2011
On preview, you solved the issue. The approach implied by the functions above works in C/C++/assembly. And I have another, even cooler approach, that works entirely by reading the Process Execution Block and walking the loaded modules. In assembly, no less.
posted by Netzapper at 1:36 PM on April 8, 2011
This thread is closed to new comments.
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
Then you'd just loop through your assemblies with something like this:
foreach (var assembly in assemblies)
{
Console.WriteLine(assembly.Location);
}
posted by geoff. at 1:26 PM on April 8, 2011