1
votes

I am sorry but I have to ask again. I am searching since many weeks and month for a solution now. The Problem is that have implemented a COM-Interface the throws only by calling a few methods an InvalidCast Exception E_NOINTERFACE and it tells me that I have to implement IUnknown. So how can I do that?

I tried nearly everything... Currently I have something like this

[ComImport,
 Guid("279AFA85-4981-11CE-A521-0020AF0BE560"),
 InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
 System.Security.SuppressUnmanagedCodeSecurity]

public interface IDirectSoundBuffer : IUnknown
{

...

[ComImport]
[Guid("00000000-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IUnknown
{
    void QueryInterface([In] ref Guid giid, [Out, MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 0)] out object ppvObject);
    [PreserveSig]
    uint AddRef();
    [PreserveSig]
    uint Release();
}

I really don t know what I could try more. I had on many different forums a topic discussing this but noboboy knows anything :(( pls help me.

1
Are you calling all the methods from your IUnknown Interface? - Botonomous
can you show the class that implements this interface? - dkackman
I also want to implement QueryInterface on my own so that I can setup logging for it - did you get it running? - Daniel Lang

1 Answers

0
votes

This is just a guess (as it has been awhile):

Do not declare IUnkown and inherit your interface from it in your C# interop code. The Com Callable Wrapper will implement it for you.