我想打印用 DLL 导入的 .NET 编译对象的内存地址。固定对象的代码是(谷歌搜索):
' dim managed variable
Dim primitiveObject As String="HELLO WORLD"
' pin variable and create
' GC handle instance
Dim gh As GCHandle = GCHandle.Alloc(primitiveObject , GCHandleType.Pinned)
' get address of variable
Dim AddrOfMyString As IntPtr = gh.AddrOfPinnedObject()
Console.WriteLine(AddrOfMyString.ToString())
' free the handle and unpin variable
gh.Free()
此代码完美运行,但我的 .NET Compiled 对象不是原始类型。
Dim myComObject as New MyDLL.MyNETObject
如何打印 myComObject 内存地址?提前致谢...