abhi294074
abhi294074

Reputation: 257

How to get current path of a dll

In my C# application we are using a dll that is in vc++,we want to know the curent path of that dll in vc++,

Upvotes: 0

Views: 264

Answers (1)

leon.io
leon.io

Reputation: 2824

If you're trying to get the location from C# you could use reflection and the GetAssembly(Type type) method

In C++

Assembly^ SampleAssembly;
// Instantiate a target object. Int32 Integer1(0); Type^ Type1; 
// Set the Type instance to the target class type. 
Type1 = Integer1.GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.
SampleAssembly = Assembly::GetAssembly( Integer1.GetType() );
// Gets the location of the assembly using file: protocol.
Console::WriteLine("CodeBase= {0}", SampleAssembly->CodeBase);

Or from your calling C# code just replace Integer1, with a type from your VC++ assembly.

Upvotes: 2

Related Questions