Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. ATL Sink in .NET process

ATL Sink in .NET process

Scheduled Pinned Locked Moved ATL / WTL / STL
c++questioncsharpcomsysadmin
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vikram1234
    wrote on last edited by
    #1

    Hello, I have an Win32 COM application with GUI written in C++ (MFC). This GUI invokes a ATL COM client/DLL that acts as a sink to a ATL COM server. Everything works well. So we have 3 components here- MFC GUI app, COM client/sink and COM event server. Now, I need to replace this native MFC C++ GUI application with .NET application. So I imported the COM dll that acts as sink into my .NET application and all interfaces were available as expected. When I make a specific method call in this COM dll/object, this method establishes sink connection with COM server (using AtlAdvise) without any issues. However, when the COM server raises an event, the call reaches the sink, but it fails in InvokeFromFuncInfo (specifically it DispCallFunc fails) from ATLCOM.h giving Access Violation error (0xC0000005). So to represent this: 1. .NET GUI ---create instance--->>> COM DLL (SINK) ---establish connection --->>>> COM Event Server 2. COM Event Server ---raise event--->>>ATLCOM.h (in COM sink DLL) fails in DispCallFunc with Access Violation (0xC0000005). The above flow works perfectly well with my MFC GUI. Is there anything required for this connectionable object or sink that I may not be setting in my .NET appliaction? How can I at least delve deeper to see what is going on? thanks! Vikram

    B T 2 Replies Last reply
    0
    • V Vikram1234

      Hello, I have an Win32 COM application with GUI written in C++ (MFC). This GUI invokes a ATL COM client/DLL that acts as a sink to a ATL COM server. Everything works well. So we have 3 components here- MFC GUI app, COM client/sink and COM event server. Now, I need to replace this native MFC C++ GUI application with .NET application. So I imported the COM dll that acts as sink into my .NET application and all interfaces were available as expected. When I make a specific method call in this COM dll/object, this method establishes sink connection with COM server (using AtlAdvise) without any issues. However, when the COM server raises an event, the call reaches the sink, but it fails in InvokeFromFuncInfo (specifically it DispCallFunc fails) from ATLCOM.h giving Access Violation error (0xC0000005). So to represent this: 1. .NET GUI ---create instance--->>> COM DLL (SINK) ---establish connection --->>>> COM Event Server 2. COM Event Server ---raise event--->>>ATLCOM.h (in COM sink DLL) fails in DispCallFunc with Access Violation (0xC0000005). The above flow works perfectly well with my MFC GUI. Is there anything required for this connectionable object or sink that I may not be setting in my .NET appliaction? How can I at least delve deeper to see what is going on? thanks! Vikram

      B Offline
      B Offline
      barneyman
      wrote on last edited by
      #2

      the obvious thing to check for is that the .net gui still has an instance of the originating com object ...

      V 1 Reply Last reply
      0
      • B barneyman

        the obvious thing to check for is that the .net gui still has an instance of the originating com object ...

        V Offline
        V Offline
        Vikram1234
        wrote on last edited by
        #3

        The sink callback happens inside the COM object. In other words, when sink establishes connection with connectionable object and then expects event from COM server, the execution control is still inside the COM sink. So the instance is alive while this happens. Could there be anything on .NET security side that I might be missing?

        B 1 Reply Last reply
        0
        • V Vikram1234

          The sink callback happens inside the COM object. In other words, when sink establishes connection with connectionable object and then expects event from COM server, the execution control is still inside the COM sink. So the instance is alive while this happens. Could there be anything on .NET security side that I might be missing?

          B Offline
          B Offline
          barneyman
          wrote on last edited by
          #4

          have a look at Understanding Classic COM Interoperability With .NET Applications[^], seems to be what you're after

          V 2 Replies Last reply
          0
          • B barneyman

            have a look at Understanding Classic COM Interoperability With .NET Applications[^], seems to be what you're after

            V Offline
            V Offline
            Vikram1234
            wrote on last edited by
            #5

            Thanks a lot! The specific section you gave a link for does look like what I am trying to do. Thanks :)

            1 Reply Last reply
            0
            • B barneyman

              have a look at Understanding Classic COM Interoperability With .NET Applications[^], seems to be what you're after

              V Offline
              V Offline
              Vikram1234
              wrote on last edited by
              #6

              Good link...What I am trying to do is slightly different though. In the post, the event sink is the .NET application it self. In my case, the event sink is another COM object and this sink COM object is instantiated from .NET application.

              B 1 Reply Last reply
              0
              • V Vikram1234

                Good link...What I am trying to do is slightly different though. In the post, the event sink is the .NET application it self. In my case, the event sink is another COM object and this sink COM object is instantiated from .NET application.

                B Offline
                B Offline
                barneyman
                wrote on last edited by
                #7

                The only other thing that comes to mind is the Dispatch pointer you're getting .. I notice you're using dispatch based callbacks into the sink? Perhaps (and i'm stabbing in the dark here ;) .Net creates your object as an aggregate object and the IDispatch you get when you query your sink, is not your's it's .NET's ?

                1 Reply Last reply
                0
                • V Vikram1234

                  Hello, I have an Win32 COM application with GUI written in C++ (MFC). This GUI invokes a ATL COM client/DLL that acts as a sink to a ATL COM server. Everything works well. So we have 3 components here- MFC GUI app, COM client/sink and COM event server. Now, I need to replace this native MFC C++ GUI application with .NET application. So I imported the COM dll that acts as sink into my .NET application and all interfaces were available as expected. When I make a specific method call in this COM dll/object, this method establishes sink connection with COM server (using AtlAdvise) without any issues. However, when the COM server raises an event, the call reaches the sink, but it fails in InvokeFromFuncInfo (specifically it DispCallFunc fails) from ATLCOM.h giving Access Violation error (0xC0000005). So to represent this: 1. .NET GUI ---create instance--->>> COM DLL (SINK) ---establish connection --->>>> COM Event Server 2. COM Event Server ---raise event--->>>ATLCOM.h (in COM sink DLL) fails in DispCallFunc with Access Violation (0xC0000005). The above flow works perfectly well with my MFC GUI. Is there anything required for this connectionable object or sink that I may not be setting in my .NET appliaction? How can I at least delve deeper to see what is going on? thanks! Vikram

                  T Offline
                  T Offline
                  ThatsAlok
                  wrote on last edited by
                  #8

                  if you import you dll in .net application,you can assign the sink method to your interface directly

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                  Never mind - my own stupidity is the source of every "problem" - Mixture

                  cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups