VB Client Crashes while using ATL COM build in C++
-
hi All, My VB Client using ATL COM works fine while running under Debug mode but in the release mode it gets crashed as ATL COM tries to fire event to the VB Client Here are the Details of what i have developed as ATL COM in C+ I have developed a simple ATL COM in C++ , This ATL Com has a dependency which is a DLL , this DLL sends a notification to the ATL COM by using a registering a function of a ATL as callback , i have used a static function of ATL Object as callback function as we cannot give member function of the class as callback function due to "this" pointer. Now Dll sends notification to this static function of ATL COM and this ATL COM send the notification further to the COM Client by firing event. Important to note , since notification is received by static function of ATL class , so i had to use global pointer to the ATL COM in that static function to Fire_Event , as soon as global pointer fires events VB client in release mode gets crashed Here is the code snippet CTest_ATL *g_pTestATL; // Glboal Pointer STDMETHODIMP CTest_ATL::funSubscribe(void) { g_pTestATL = this; m_hDLL = LoadLibrary(TEXT("\\DLL_PlaceCall.dll")); if(NULL == m_hDLL) { return S_FALSE; } return S_OK; } // This is a callback "static" function which gets registered to the DLL // As this static callback function gets called i am firing event using // global pointer to ATL_COM as shown below int CTest_ATL::EventCallBack() { g_CallMonitor->Fire_IncomingCall(CComBSTR("This is a COM Message")); return S_OK; } Any pointers in this issue will be a great help..... with regards Abhiraj
-
hi All, My VB Client using ATL COM works fine while running under Debug mode but in the release mode it gets crashed as ATL COM tries to fire event to the VB Client Here are the Details of what i have developed as ATL COM in C+ I have developed a simple ATL COM in C++ , This ATL Com has a dependency which is a DLL , this DLL sends a notification to the ATL COM by using a registering a function of a ATL as callback , i have used a static function of ATL Object as callback function as we cannot give member function of the class as callback function due to "this" pointer. Now Dll sends notification to this static function of ATL COM and this ATL COM send the notification further to the COM Client by firing event. Important to note , since notification is received by static function of ATL class , so i had to use global pointer to the ATL COM in that static function to Fire_Event , as soon as global pointer fires events VB client in release mode gets crashed Here is the code snippet CTest_ATL *g_pTestATL; // Glboal Pointer STDMETHODIMP CTest_ATL::funSubscribe(void) { g_pTestATL = this; m_hDLL = LoadLibrary(TEXT("\\DLL_PlaceCall.dll")); if(NULL == m_hDLL) { return S_FALSE; } return S_OK; } // This is a callback "static" function which gets registered to the DLL // As this static callback function gets called i am firing event using // global pointer to ATL_COM as shown below int CTest_ATL::EventCallBack() { g_CallMonitor->Fire_IncomingCall(CComBSTR("This is a COM Message")); return S_OK; } Any pointers in this issue will be a great help..... with regards Abhiraj
garammasala wrote:
My VB Client using ATL COM works fine while running under Debug mode but in the release mode it gets crashed as ATL COM tries to fire event to the VB Client
Do you have any code you depend on inside an ATLASSERT statement? These are removed in release builds. Another possibility is that the optomizer is breaking something. You may want to create a release build with debug information so that you can step through the code the compiler is actually generating for the release build. Also, unrelated to your problem, it looks to me like g_pTestATL and g_CallMonitor could be static member variables of CTest_ATL. Nathan
-
garammasala wrote:
My VB Client using ATL COM works fine while running under Debug mode but in the release mode it gets crashed as ATL COM tries to fire event to the VB Client
Do you have any code you depend on inside an ATLASSERT statement? These are removed in release builds. Another possibility is that the optomizer is breaking something. You may want to create a release build with debug information so that you can step through the code the compiler is actually generating for the release build. Also, unrelated to your problem, it looks to me like g_pTestATL and g_CallMonitor could be static member variables of CTest_ATL. Nathan
Hi Nathan < Also, unrelated to your problem, it looks to me like g_pTestATL and g_CallMonitor could be static member variables of CTest_ATL > I made a mistake while giving the question i.e "g_CallMonitor" is nothing it is the global pointer "g_pTestATL" which is firing the event from the static function.... replace g_CallMonitor with g_pTestATL I have found the solution to the problem but was not really able to understand the whole solution , Below is the link http://vcfaq.mvps.org/com/1.htm May be you can through some light....
-
Hi Nathan < Also, unrelated to your problem, it looks to me like g_pTestATL and g_CallMonitor could be static member variables of CTest_ATL > I made a mistake while giving the question i.e "g_CallMonitor" is nothing it is the global pointer "g_pTestATL" which is firing the event from the static function.... replace g_CallMonitor with g_pTestATL I have found the solution to the problem but was not really able to understand the whole solution , Below is the link http://vcfaq.mvps.org/com/1.htm May be you can through some light....
garammasala wrote:
I made a mistake while giving the question i.e "g_CallMonitor" is nothing it is the global pointer "g_pTestATL" which is firing the event from the static function.... replace g_CallMonitor with g_pTestATL
That makes perfect sense. :)
garammasala wrote:
I have found the solution to the problem but was not really able to understand the whole solution , Below is the link http://vcfaq.mvps.org/com/1.htm[^] May be you can through some light....
I'm not sure what you don't understand. I assume that you've implemented one of the options and had it work, because otherwise you wouldn't know for sure it was a solution. I've used both the hidden window and the GIT solution, so I may be able to answer any more specific questions you might have about them. In general, using multiple threads well will require lots of studying and lots of practice. There are probably articles on CodeProject that can tell you a lot about it. Nathan
-
garammasala wrote:
I made a mistake while giving the question i.e "g_CallMonitor" is nothing it is the global pointer "g_pTestATL" which is firing the event from the static function.... replace g_CallMonitor with g_pTestATL
That makes perfect sense. :)
garammasala wrote:
I have found the solution to the problem but was not really able to understand the whole solution , Below is the link http://vcfaq.mvps.org/com/1.htm[^] May be you can through some light....
I'm not sure what you don't understand. I assume that you've implemented one of the options and had it work, because otherwise you wouldn't know for sure it was a solution. I've used both the hidden window and the GIT solution, so I may be able to answer any more specific questions you might have about them. In general, using multiple threads well will require lots of studying and lots of practice. There are probably articles on CodeProject that can tell you a lot about it. Nathan
yes Nathan Your are right that i have implemented one of the options and my work was done... Since ATL COM is very vast so no idea where to start exactly to find the solution for the same ,also the solution given in the link which i gave requires a lot of deep understanding of ATL before the solution provided can be understood, As you have said there are so many articles in the Code project that can tell me a lot better about ATL and basically the solution given in the links... so will request to point some of those if you can... ? with regards Abhiraj
modified on Monday, April 28, 2008 1:38 PM