How I do With struct** ???? RRS feed

  • Question

  • Hello!

    I need to do a COM interop between a C# new application and C++ legacy application.
    The method from COM object that I need call have this IDL description:

            void BuscaPonteiros(
                            [IN] Struct1 struct1,
                            [IN] Struct2 struct2,
                            [OUT] Struct3** struct3)

    When TlbImp is runned, the third parameter is converted to out IntPtr struct3. This parameter is set by "BuscaPonteiros" method, through CoTaskMemAlloc.

    In C# I call this method this way:

        p.BuscaPonteiros(..., ..., out iPtr);

    And the error message "A null reference ponter was passed to the stub. (Exception from HRESULT 0x800706F4)"

    Can somebody help me?

    Thanks a lot.


    Roosevelt dos Santos Júnior
    Friday, June 27, 2008 1:56 PM

All replies

  • That's an RPC error.  That has little to do with your P/Invoke call, something blows up inside the C++ component.  Use an unmanaged debugger to find out why it is failing.
    Hans Passant.
    Saturday, June 28, 2008 12:53 AM
  • Hi... thanks for your reply!

    I already try to do it, but the debugger doesn't stopped/called when the C# Interop method is called. The error happen before.

    Thanks again.
    Roosevelt dos Santos Júnior
    Saturday, June 28, 2008 2:28 AM
  • Unlikely, but verify that: edit the P/Invoke declaration and remove all the arguments.  That won't make the function work but you'll at least get a break at the unmanaged function's entry point.
    Hans Passant.
    Saturday, June 28, 2008 7:49 AM
  • I just test this way and work very well. I believe that the problem is how the TLBIMP convert the method  signature, or the problem is how I'm building the IntPtr to to the call method with struct** parameter.

    Roosevelt dos Santos Júnior
    Saturday, June 28, 2008 1:26 PM
  • Tell us more about the C++ code.  Is this an out-of-process COM server?
    Hans Passant.
    Saturday, June 28, 2008 1:46 PM
  • Hello!

    Yes, is it an out-of-process COM server. But I've solved writting a DLL to glue my .NET Code.

    Roosevelt dos Santos Júnior
    Sunday, August 10, 2008 2:26 PM