Groups | Blog | Home
all groups > dotnet interop > may 2005 >

dotnet interop : Manually implement COM interface in C#???



Zhenxin Li
5/14/2005 12:00:00 AM
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

Mattias Sjögren
5/14/2005 12:00:00 AM

[quoted text, click to view]

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
Zhenxin Li
5/14/2005 12:00:00 AM
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

[quoted text, click to view]

AddThis Social Bookmark Button