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


hello,

i'm using c# access vssapi, works fine until call this method <<ivssexaminewritermetadata.getcomponent()>>.

if use form a, the method returns me notimplementedexception.
if use form b, success , intptr contains real pointer.

with intptr, map to my c# ivsswmcomponent class in order call method ?

when see c++ header file, notice that ivssexaminewritermetadata using a <<__declspec>> while 
ivsswmcomponent not. difference.

thank helping me.




here c# implementation

    [guid("902fcf7f-b7fd-42f8-81f1-b2e400b1e5bd")]
    [interfacetype(cominterfacetype.interfaceisiunknown)]
    public interface ivssexaminewritermetadata
    {
        // form a 
        [return: marshalas(  unmanagedtype.interface ) ]
        ivsswmcomponent getcomponent( uint icomponent);

        // form b 
        void getcomponent( uint icomponent, out intptr pcomponent );
    }


    [interfacetype(cominterfacetype.interfaceisiunknown)]
    public interface ivsswmcomponent
    {
        ....
    }

here c++ implementation:

// interface examine writer metadata
class __declspec(uuid("902fcf7f-b7fd-42f8-81f1-b2e400b1e5bd")) ivssexaminewritermetadata : public iunknown
 {

     // obtain specific component
     stdmethod(getcomponent)
      (
      in uint icomponent,
      out ivsswmcomponent **ppcomponent
      ) = 0;

 }


// component information
class ivsswmcomponent : public iunknown
 {
 ....
 }



 

you should use type library , tlbimp.exe these declarations correct.  have no idea you'd it.  real declaration getcomponent method is:

  int getcomponent(uint index, out ivsswmcomponent component);

the return value hresult, 0 indicates success.

hans passant.


.NET Framework  >  Common Language Runtime Internals and Architecture



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'