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. C / C++ / MFC
  4. Please help immediately!!

Please help immediately!!

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++debuggingperformancequestion
6 Posts 4 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.
  • A Offline
    A Offline
    angello6
    wrote on last edited by
    #1

    :(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

    J J 2 Replies Last reply
    0
    • A angello6

      :(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

      J Offline
      J Offline
      John R Shaw
      wrote on last edited by
      #2

      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

      D J 2 Replies Last reply
      0
      • J John R Shaw

        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

        D Offline
        D Offline
        david_gilmour
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • J John R Shaw

          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

          J Offline
          J Offline
          Jon Hulatt
          wrote on last edited by
          #4

          "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;

          J 1 Reply Last reply
          0
          • A angello6

            :(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

            J Offline
            J Offline
            Jon Hulatt
            wrote on last edited by
            #5

            "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;

            1 Reply Last reply
            0
            • J Jon Hulatt

              "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;

              J Offline
              J Offline
              John R Shaw
              wrote on last edited by
              #6

              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

              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