Tech Off Thread

6 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

WebBrowser in Windows Forms

Back to Forum: Tech Off
  • User profile image
    Jernej

    Ever tryed to use web browser coponent on window forms?
    It works by using COM interop (AxInterop.SHDocVw.dll)

    But I always get exceptions when I use it! Try it, create an empty winfws form, add web browser control to it and turn on "break on CRL exceptions". When program gets to instruction

    ((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();

    error message:
    A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in system.windows.forms.dll

    Additional information: Unknown error

    I used to ignore this error while it didn't affect my program.

    But since I've installed the latest Crystal reports servie packs, I can't use reports any more! Expressionless

    It fails when a program calls:

    CrystalDecisions.CrystalReports.Engine.ReportDocument r = 
       new CrystalDecisions.CrystalReports.Engine.ReportDocument();

    And the error:

    A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in crystaldecisions.crystalreports.engine.dll

    Additional information: Unknown error

    I spent days investigating what was the cause! And I found out that if I outcomment all the web browser related stuff, crystal reports work as they used to!?

    I guess web browser somehow corrupts COM interop and that's why crystal (which also uses interop!) fails.

    I'm stucked now. I must have browser control in my application (since previous versions do), but obviously I also need reports. Reverting to previous crystal reports version didn't help (using crystal's restore.exe).

    (b) If you find a solution, the beer's on me Wink

    J

  • User profile image
    Jernej

    Well... if I dont' find a solution, I will have to embed mozilla (http://www.iol.ie/~locka/mozilla/mozilla.htm), while this is the only workarround I currently know of. This really shouldn't be my only option Sad

    J

  • User profile image
    Vijay

    hmm .. Think i've seen this before.

    The error i guess specifically occurs when the resource file used for the designer of the ActiveX webbrowser control is corrupted with invalid values. Probably you should try to search for an example in Google.

    Also several such problems related to the webbrowser control have been discussed in Experts Exchange site and many other newsgroups. That should get you started !

  • User profile image
    Fábio

    HI EVERYBODY,
    I GOT THIS ERROR ONCE WITH "IMPORTS EXCEL", IT GOT FIXED BY CHANGING THE current CultureInfO.

    LOCATION:
     http://msdn.microsoft.com/library/en-us/dv_wrcore/html/wrconglobalizinglocalizingofficesolutions.asp?frame=true


    I'VE ADDED AN AXOWC10 - MSO WEB COMPONENT,AND I GOT IT AGAIN AND IT DIDN'T WORK WITH THAT !

    DID YOU FIND OUT THE ERROR ?

    BEST REGARDS,
    FÁBIO DIAS

  • User profile image
    scumbies

    Hi, just for the record... while this is obviously still a bug of some kind, I was able to get around it by NOT breaking on exceptions.

    Go, Debug | Exceptions and then, for CLR exceptions, set it to continue when the exception is thrown.

    Obviously, this can be a real pain if you WANT it to break on exceptions (like I do!). But I haven't got an alternative as yet.

    If anyone does have a better solution, please share it.

    Stu

  • User profile image
    Steev

    "But I always get exceptions when I use it! Try it, create an empty winfws form, add web browser control to it and turn on "break on CRL exceptions". When program gets to instruction
    ((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();"


    I had the exact same problem and fixed it completely by chance Wink.  I happened to have a breakpoint in my form_load() method.  When EndInit() got called, my breakpoint was hit.  It seemed fairly odd, because the load method usually only gets called when your form is about to be shown, not when it's constructed, (which is when my call to InitializeComponents() occurred).

    The fix was to keep a boolean flag that I initialized to false and set to true after the call to InitializeComponents().  Then, if the boolean was false (pre-initialization), the load method would navigate the browser control to "about:blank" (I found was necessary to navigate it to somewhere or the form would not display properly in the design view).  If the boolean was true (post-initialization), the load method would do what it would normally do.

    Hopefully that makes some sense Smiley

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.