Please help immediately!!
-
:(Hi All! I am getting debug assertion error exactly at the fourth time i open Webbrowser Control, consistently, everytime. CAN ANYONE HELP? Any help on this regards will be appreciated !:sigh: I have two components, one is a MFC Application and the other is a Dll. I have a Webbrowser control in the dll, that is accessed by the MFC App. The following code calls the Webbrowsercontrol, which is in the dll, by the foll code: "CWebDialog* wb; wb = new CWebDialog(); wb->DoModal(); " This code calls the Webbrowser control cpp, in the dll, whose Initdialog has the foll: BOOL CWebDialog::OnInitDialog() { USES_CONVERSION; CoInitialize(NULL); try { hf_WriteLog("ONINITDLGWEB"); COleVariant vaURL(m_strURL); ((CWebBrowser2*)GetDlgItem(IDC_EXPLORER1))->Navigate2(vaURL, NULL, NULL, NULL, NULL); hf_WriteLog("NAVIGATED"); VariantClear(&vaURL); CoUninitialize(); CDialog::OnInitDialog(); } This throws an exception, every fourth time. Is that a problem with the memory allocation of the dll.. or anything, someone could help???????? :(( Regards angello6 Regds Angello
-
:(Hi All! I am getting debug assertion error exactly at the fourth time i open Webbrowser Control, consistently, everytime. CAN ANYONE HELP? Any help on this regards will be appreciated !:sigh: I have two components, one is a MFC Application and the other is a Dll. I have a Webbrowser control in the dll, that is accessed by the MFC App. The following code calls the Webbrowsercontrol, which is in the dll, by the foll code: "CWebDialog* wb; wb = new CWebDialog(); wb->DoModal(); " This code calls the Webbrowser control cpp, in the dll, whose Initdialog has the foll: BOOL CWebDialog::OnInitDialog() { USES_CONVERSION; CoInitialize(NULL); try { hf_WriteLog("ONINITDLGWEB"); COleVariant vaURL(m_strURL); ((CWebBrowser2*)GetDlgItem(IDC_EXPLORER1))->Navigate2(vaURL, NULL, NULL, NULL, NULL); hf_WriteLog("NAVIGATED"); VariantClear(&vaURL); CoUninitialize(); CDialog::OnInitDialog(); } This throws an exception, every fourth time. Is that a problem with the memory allocation of the dll.. or anything, someone could help???????? :(( Regards angello6 Regds Angello
I do not know, but even in a try block you have to check return values to make sure the functions have succeded. CoInitialize(0) should be called at program startup and CoUninitialize() should be called at program shutdown, not every time you call OnInitDialog(). May be that is the problem. If you told the application wizard (when generating project) that you were going to use COM objects, then it has already inserted code for those 2 functions. The problem can also be in the DLL. Good Luck and Good Night! INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
-
I do not know, but even in a try block you have to check return values to make sure the functions have succeded. CoInitialize(0) should be called at program startup and CoUninitialize() should be called at program shutdown, not every time you call OnInitDialog(). May be that is the problem. If you told the application wizard (when generating project) that you were going to use COM objects, then it has already inserted code for those 2 functions. The problem can also be in the DLL. Good Luck and Good Night! INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
Try to move CDialog::OnInitDialog to the first line of your CWebDialog::OnInitDialog function Between the great things we cannot do and the small things we will not do, the danger is that we shall do nothing
-
I do not know, but even in a try block you have to check return values to make sure the functions have succeded. CoInitialize(0) should be called at program startup and CoUninitialize() should be called at program shutdown, not every time you call OnInitDialog(). May be that is the problem. If you told the application wizard (when generating project) that you were going to use COM objects, then it has already inserted code for those 2 functions. The problem can also be in the DLL. Good Luck and Good Night! INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
"CoInitialize(0) should be called at program startup and CoUninitialize() should be called at program shutdown, not every time you call OnInitDialog()" Thats not true. CoInitialize should be called at least once per thread; and every CoInitialize should have a corresponding CoUninitialize(). Furthemore, CoInitialize is deprecated, and you ought to be using CoInitializeEx instead.
using System.Beer;
-
:(Hi All! I am getting debug assertion error exactly at the fourth time i open Webbrowser Control, consistently, everytime. CAN ANYONE HELP? Any help on this regards will be appreciated !:sigh: I have two components, one is a MFC Application and the other is a Dll. I have a Webbrowser control in the dll, that is accessed by the MFC App. The following code calls the Webbrowsercontrol, which is in the dll, by the foll code: "CWebDialog* wb; wb = new CWebDialog(); wb->DoModal(); " This code calls the Webbrowser control cpp, in the dll, whose Initdialog has the foll: BOOL CWebDialog::OnInitDialog() { USES_CONVERSION; CoInitialize(NULL); try { hf_WriteLog("ONINITDLGWEB"); COleVariant vaURL(m_strURL); ((CWebBrowser2*)GetDlgItem(IDC_EXPLORER1))->Navigate2(vaURL, NULL, NULL, NULL, NULL); hf_WriteLog("NAVIGATED"); VariantClear(&vaURL); CoUninitialize(); CDialog::OnInitDialog(); } This throws an exception, every fourth time. Is that a problem with the memory allocation of the dll.. or anything, someone could help???????? :(( Regards angello6 Regds Angello
"I am getting debug assertion error exactly at the fourth time" "This throws an exception, every fourth time" so which is it? an assertation? or an exception? Did you try stepping through the code to see which line causes the problem?
using System.Beer;
-
"CoInitialize(0) should be called at program startup and CoUninitialize() should be called at program shutdown, not every time you call OnInitDialog()" Thats not true. CoInitialize should be called at least once per thread; and every CoInitialize should have a corresponding CoUninitialize(). Furthemore, CoInitialize is deprecated, and you ought to be using CoInitializeEx instead.
using System.Beer;
True, calling the CoInitialize(0) followed by a call to CoUnitialize() should not cause a problem. A dialog window, like probably every other window, is in the applications thread, so if you call CoInitialize(0) at app-startup and CoUnitialize() at app-shutdown, then any other call will be redundant (unless called in a new thread). Once the programmer has implimented proper error checking and makes sure any resources used are proberly released, the problem should go away. Jon Hulatt wrote: you ought to be using CoInitializeEx instead TRUE INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen