none
AxSHDocVw.AxWebBrowser breaks on Windows 2003 Server

    Question

  •  

    Hello,

     

    I have a C# application that has the AxSHDocVw.AxWebBrowser control on it. When a user presses a button it will convert some data to HTML to display on the form.  On a Windows XP machine this application works fine, however, when I install it on a Windows 2003 Server, press the button to convert to HTML the control just flickers and nothing happens. To me it seems like something with the way Internet Explorer is configured on 2003, I saw that my shdocvw.dll on XP was version 6.0.2900.3157 and the version on the 2003 Server was 6.0.3790.2954, so the server one is newer and may handle things differently. Does anyone know of problems with AxSHDocVw.AxWebBrowser on a Windows 2003 Server?

     

    Thanks,

    Flea#

     

     

    Tuesday, January 29, 2008 7:00 PM

Answers

  • I have resolved the issue for this. The problem was the server did not have microsoft.mshtml.dll installed and registered in the GAC. Apparently the error was being supressed in the navigate events. When I pulled the code out of the event and just placed it into the event for the button it revealed this was missing.

     

    Steps to do this:

    microsoft.mshtml.dll needs to be copied to the server, installed in the Global Assembly Cache (GAC) using the Global Assembly Cache tool (gacutil /i microsoft.mshtml.dll), and then registered using the Assembly Registration Tool (regasm microsoft.mshtml.dll).

     

    -Flea#

     

    Additional information can be found here:

    http://support.microsoft.com/kb/934368

    http://blogs.msdn.com/infopath/archive/2004/09/27/234911.aspx

    Thursday, January 31, 2008 10:04 PM

All replies

  • it more likely your code can not work with Internet Explorer Enhanced Security

     

    Tuesday, January 29, 2008 9:56 PM
    Moderator
  • Hi Sheng,


    I went to Add/Remove programs, Windows Componets and then int Internet Explorer and un-installed the Enhanced Security.  This seemed to not have any effect though.


    Thanks,

    Flea

     

     

    Tuesday, January 29, 2008 10:08 PM
  • mmm

    How you display HTML on the form?

     

    Tuesday, January 29, 2008 11:28 PM
    Moderator
  • I have placed a webbrowser control onto a form. Basically, I have a file full of string data. The user has an option to press a button to parse the data out into XML or as HTML which is displayed to them on the screen. THe XML goes to its own control and the HTML goes to the webbrowser control.

     

    OK, so on Windows XP, the application works just fine, it parses the data as XML or HTML but when I move the application to Windows 2003 Server, when I press the button for just HTML, the webbrowser control just flickers at me and nothing is ever loaded nor are any errors thrown.

     

    Here is the code for the button and when that is pressed I am doing the actual HTML portion in the NavigationComplete2 event.

     

    Code Snippet

    private void htmlSerializeButton_Click(object sender, System.EventArgs e)

    {

    try

    {

    this.webBrowser.Navigate("about:blank");

    }

    catch (Exception ex)

    {

    MessageBox.Show(ex.ToString());

    }

    }

     

     

    Code Snippet

    private void webBrowser_NavigateComplete2(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)

    {

    try

    {

    // Load the iso message

    this.LoadIsoMessage();

     

    IHTMLDocument2 htmlDocument = (IHTMLDocument2)webBrowser.Document;

    IHTMLElement body = (IHTMLElement)htmlDocument.body;

    StringBuilder stringBuilder = new StringBuilder();

    StringWriter stringWriter = new StringWriter(stringBuilder);

    ISOHtmlSerializer serializer = new ISOHtmlSerializer();

    serializer.Serialize(stringWriter, this.isoMessage);

    body.innerHTML = stringWriter.ToString();

    }

    catch (Exception ex)

    {

    MessageBox.Show(ex.ToString());

    }

    }

     

     

    I did notice that the shdocvw.dll versions are different, which probably could be expected. 

     

    XP shdocvw.dll version = 6.0.2900.3157

    2003 Server shdocvw.dll version = 6.0.3790.3041

     

    This is a .Net 1.1 framework app and the server comes pre-loaded with 1.1.  Any other possible ideas? Again, I removed the enhanced security from Add/Remove  Windows Componets but that didn't make a difference.

     

    Thanks,

    Flea#

     

     

    Wednesday, January 30, 2008 10:43 PM
  • I can not reproduce your problem on my 2003 machine w/ VS2005. Here is my code

    Code Snippet

     private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
            {
                webBrowser1.Document.Body.InnerHtml = "<HTML><BODY><H><I>Test</I></H></BODY></HTML>";
            }

            private void Form1_Load(object sender, EventArgs e)
            {
                webBrowser1.Navigate("about:blank");
            }

     

     

    Try a simple HTML string to see if it makes a difference. Setting innerHtml is not the best way to construct a Document Object Model. You should consider using IPersistStreamInit/IPersistMoniker to load string into webbrowser.

    Wednesday, January 30, 2008 11:02 PM
    Moderator
  • Sheng,

     

    I cannot use the above example because it is using the webbrowser control in .NET 2.0.  I am developing this in 1.1 which requires me to use the ActiveX control. 

     

    -Flea#

     

    Wednesday, January 30, 2008 11:15 PM
  • I don't think the .Net wrapper would make a behavior difference in this scenario. I do see a lot of flickering problems when you replace innerText, even when using javascript. I suggest use one of the IPersist interfaces to load HTML content.

    Wednesday, January 30, 2008 11:28 PM
    Moderator
  • You know what I found interesting Sheng, on the Windows 2003 Server, the webBrowser_NavigateComplete2 is never being called.  I went into my code and placed simple message boxes within the NavigateComplete2 method just at the begining, middle and end and when I compile and run the code on the XP machine, the message boxes pop up. However, when I run it on the 2003 Server, the event is never fired because the message boxes never appear. So for some reason it seems something is getting blocked.

     

    Thanks,

    Flea

     

    Thursday, January 31, 2008 2:51 PM
  • I have resolved the issue for this. The problem was the server did not have microsoft.mshtml.dll installed and registered in the GAC. Apparently the error was being supressed in the navigate events. When I pulled the code out of the event and just placed it into the event for the button it revealed this was missing.

     

    Steps to do this:

    microsoft.mshtml.dll needs to be copied to the server, installed in the Global Assembly Cache (GAC) using the Global Assembly Cache tool (gacutil /i microsoft.mshtml.dll), and then registered using the Assembly Registration Tool (regasm microsoft.mshtml.dll).

     

    -Flea#

     

    Additional information can be found here:

    http://support.microsoft.com/kb/934368

    http://blogs.msdn.com/infopath/archive/2004/09/27/234911.aspx

    Thursday, January 31, 2008 10:04 PM