CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Location
    Minnesota
    Posts
    175

    Marshal.GetIDispatchForObject

    Does anyone know if it is possible to create an IDispatch pointer out of a C# class to pass to a C++ object expecting an IDispatch pointer? I assume I have to create an interface, but how do I pass that interface as a pointer?

    Code:
    // C++ Executable expecting a COM IDispatch pointer
    CCOW.ContextManager cm = new CCOW.ContextManager()
    
    // C# dll
    ContextParticipant .ContextParticipant icp = new ContextParticipant .ContextParticipant();
    
    IntPtr iDispatchPtr = Marshal.GetIDispatchForObject(icp);
    
    cm.JoinCommonContext(iDispatchPtr);
    When I execute the above code the iDispatchPtr contains a value when running in debug, but when I try to use it in the C++ control it becomes NULL.

    Any thoughts?

    Thanks in advance!

  2. #2
    Join Date
    Oct 2003
    Location
    Minnesota
    Posts
    175

    Re: Marshal.GetIDispatchForObject

    Anyone have any ideas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured