Multimobile Development: Building Applications for any Smartphone
Manually implement COM interface in C#?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.interop.


Zhenxin Li
Hello,

I want to implement IUPnPServiceCallback in C#. This interface is not in the
typelib of UPnP dll, so I must implement it myself. Are there any references
to implement COM interface in C# manually?

Best regards,
Zhenxin Li

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Mattias Sjögren
[Original message clipped]

Try this declaration

[ComImport, Guid("31fadca9-ab73-464b-b67d-5c1d0f83c8b8"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IUPnPServiceCallback
{
    void StateVariableChanged(IUPnPService pus,
     [MarshalAs(UnmanagedType.LPWStr)] string pcwszStateVarName,
     object vaValue);
    void ServiceInstanceDied(IUPnPService pus);
}

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Zhenxin Li
Thanks! Every function works well. I also use Marshal::QueryInterface to
test it. It returns non-zero interface pointer.

But I don't get any notification from UPnP. I doubt whether my UPnP router
supports callback.

Best regards,
Zhenxin Li

"Mattias Sj?gren" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
 
System.Runtime.InteropServices.ComInterfaceType
System.Runtime.InteropServices.UnmanagedType




Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Copyright © AMX Software Ltd 2008-2012. Portions copyright © Matthew Baxter-Reynolds 2001-2012. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734

Hi! 10 years ago I founded .NET 247. I am working on a new and exciting replacement for the site. Please join me on Twitter to discuss.

Thanks,
Matthew Baxter-Reynolds (@mbrit)

Follow mbrit on Twitter