如何获取dll的当前路径

时间:2012-05-28 11:43:49

标签: .net visual-c++

在我的C#应用​​程序中,我们使用的是vc ++中的dll,我们想知道vc ++中该DLL的实用路径,

1 个答案:

答案 0 :(得分:2)

如果你想从C#获取位置,你可以使用反射和GetAssembly(Type type) method

在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);

或者从您调用的C#代码中,用VC ++程序集中的类型替换Integer1。

相关问题