ATL Sink in .NET process
-
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
-
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
-
the obvious thing to check for is that the .net gui still has an instance of the originating com object ...
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?
-
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?
-
have a look at Understanding Classic COM Interoperability With .NET Applications[^], seems to be what you're after
Thanks a lot! The specific section you gave a link for does look like what I am trying to do. Thanks :)
-
have a look at Understanding Classic COM Interoperability With .NET Applications[^], seems to be what you're after
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.
-
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.
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 ?
-
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
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" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You