VB.Net to COM Marshalling

G

Guest

I am using a COM interface decalared as follows from VB.Net

interface ISample : IDispatch
{
[id(1), helpstring("method WriteSample")] HRESULT Write(long* pBuffer )
}

In VB.Net, I get the address from the call below and pass it to the "Write"
function which is declared as

Write( Byref pBuffer as Integer )

.....
Dim ptrBuffer As Integer = playbackArrayHandle.AddrOfPinnedObject.ToInt32
obj.Write( ptrBuffer )

However, the COM object receives the pointer as a long** or a
pointer-to-pointer to a long. How can I fix this?

Thanks
Hemal
 
M

Mattias Sjögren

However, the COM object receives the pointer as a long** or a
pointer-to-pointer to a long. How can I fix this?

Don't use any GCHandle, just pass in the Integer value you want
directly.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top