Error when retrieving a C++ class from VssApi.dll ? RRS feed

  • Question

  • Hello,

    I'm using C# to access VssApi, everything works fine until i call this method <<IVssExamineWriterMetadata.GetComponent()>>.

    If i use the FORM A, the method returns me a NotImplementedException.
    If i use the FORM B, i get a success and the IntPtr contains a real pointer.

    With an IntPtr, what to do to map it to my C# IVssWMComponent class in order to call its method ?

    When i see the C++ header file, i notice that IVssExamineWriterMetadata is using a <<__declspec>> while 
    IVssWMComponent does not. This is the difference.

    Thank you for helping me.


        public interface IVssExamineWriterMetadata
            // FORM A 
            [return: MarshalAs(  UnmanagedType.Interface ) ]
            IVssWMComponent GetComponent( uint iComponent);

            // FORM B 
            void GetComponent( uint iComponent, out IntPtr pComponent );

        public interface IVssWMComponent


    // interface to examine writer metadata
    class __declspec(uuid("902fcf7f-b7fd-42f8-81f1-b2e400b1e5bd")) IVssExamineWriterMetadata : public IUnknown

         // obtain specific component
          IN UINT iComponent,
          OUT IVssWMComponent **ppComponent
          ) = 0;


    // component information
    class IVssWMComponent : public IUnknown


    Thursday, January 8, 2009 10:22 AM

All replies

  • You should use a type library and Tlbimp.exe to get these declarations correct.  I have no idea where you'd get it.  The real declaration for the GetComponent method is:

      int GetComponent(uint index, out IVssWMComponent component);

    The return value is a HRESULT, 0 indicates success.

    Hans Passant.
    Thursday, January 8, 2009 12:07 PM
  • Tlbimp.exe does not function on a VssApi.dll

    TlbImp : error TI0000 : The input file 'c:\windows\system32\vssapi.dll' is not a
     valid type library.

    All C# implementation described above are of my own.

    Of course, to stick to the real C++ declaration that is 
        int GetComponent(uint index, out IVssWMComponent component);

    Do not forget to add the C# attribute PreserveSigAttribute
        // FORM C
        int GetComponent(uint index, out IVssWMComponent component);

    .NET lets you manage on your behalf the returned HRESULT as i use it in FORM A and FORM B above.

    When i use now FORM A or FORM C, i always get the following error : 
        NotImplementedException (Exception of HRESULT : 0x80004001 (E_NOTIMPL))

    When i use FORM B, i always get a successful call and a valid IntPtr, but i do not know what to do with IntPtr to map it to a C# class ????

    Thank you
    Thursday, January 8, 2009 12:28 PM