Am I using the correct signature?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.interop.

Post a new message to this list...

Shahid
Greetings,

I am having trouble passing a pointer of type
IVSMDCodeDomProvider from Visual C++ (ATL) to managed
code in Vb.net.

The following is the Visual C++ code:
***
CComPtr<IVSMDCodeDomProvider> pCD;
// ... The above pointer is made to point to an existing
file

long TempLong;
TempLong = (long)(pCD.p);
hr = Managed_Method(&TempLong);
***

The following is the Vb.net code:
***
Public Function Managed_Method(<InAttribute(),
OutAttribute(), MarshalAs(UnmanagedType.Interface)> ByRef
    pCodeDomProvider As IntPtr) As String Implements
ISomeInterface.Managed_Method

Dim pCDInterface As IVSMDCodeDomProvider
pCDProvider = Marshal.GetTypedObjectForIUnknown(
pCodeDomProvider, System.Type.GetType
("Microsoft.VisualStudio.Designer.Interfaces.IVSMDCodeDomP
rovider")
Dim pCDProvider As System.CodeDom.Compiler.CodeDomProvider
pCDProvider = pCDInterface.pCodeDomProvider
// ... The problem is that this pCDProvider is Nothing ...

End Function

***

Regards,

Shahid.
Reply to this message...
 
    
Mattias Sjögren
Shahid,

Why are you making things so complicated? Have you tried to simply
make it

Public Function Managed_Method(ByVal pCodeDomProvider As
IVSMDCodeDomProvider) As String Implements
ISomeInterface.Managed_Method

Mattias

===
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Reply to this message...
 
    
Shahid
Hello Mattias,

I also tried this approach but the object received in the
managed code is still null (Nothing in Vb.net).

By the way, after making the signature on the Managed
side to the one you've mentioned, the signature on the
Visual C++ side became as:

"
BSTR Managed_Method([in] IUnknown *pCodeDomProvider);
"

I don't know why this is not working so any help would be
deeply appreciated.

Regards,

Shahid.

[Original message clipped]

Reply to this message...
 
 
System.CodeDom.Compiler.CodeDomProvider
System.IntPtr
System.Runtime.InteropServices.InAttribute
System.Runtime.InteropServices.Marshal
System.Runtime.InteropServices.OutAttribute
System.Runtime.InteropServices.UnmanagedType
System.Type




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com