AxWebBrowser not firing events in production

D

DJPoobs

Hi,


I can not get NavigateComplete2 and DownloadComplete events
from the object AxSHDocVw.AxWebBrowser to fire on production.


I have tested on computers having Visual Studio.NET installed and
everything goes well.


But I tested on computers not having Visual Studio.NET under Windows XP
and has the framework and the events will not fire

code iam using

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using mshtml;


namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
///
public class Form1 : System.Windows.Forms.Form
{
public SHDocVw.WebBrowser_V1 ie;

// Declare a new ButtonArray object.
private System.Windows.Forms.Button button3;
private AxSHDocVw.AxWebBrowser axWebBrowser1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

ie = (SHDocVw.WebBrowser_V1)this.axWebBrowser1.Application;
this.ie.BeforeNavigate +=new
SHDocVw.DWebBrowserEvents_BeforeNavigateEventHandler(ie_BeforeNavigate);
this.ie.DownloadComplete +=new
SHDocVw.DWebBrowserEvents_DownloadCompleteEventHandler(ie_DownloadComplete);

//
// TODO: Add any constructor code after InitializeComponent call
//
}


/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));
this.button3 = new System.Windows.Forms.Button();
this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();
this.SuspendLayout();
//
// button3
//
this.button3.Location = new System.Drawing.Point(344, 152);
this.button3.Name = "button3";
this.button3.TabIndex = 2;
this.button3.Text = "button3";
//
// axWebBrowser1
//
this.axWebBrowser1.Enabled = true;
this.axWebBrowser1.Location = new System.Drawing.Point(128, 64);
this.axWebBrowser1.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState")));
this.axWebBrowser1.Size = new System.Drawing.Size(300, 150);
this.axWebBrowser1.TabIndex = 3;
this.axWebBrowser1.Enter += new
System.EventHandler(this.axWebBrowser1_Enter);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(504, 414);
this.Controls.Add(this.axWebBrowser1);
this.Controls.Add(this.button3);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}



private void axWebBrowser1_Enter(object sender, System.EventArgs e)
{
object o = "about:blank";
axWebBrowser1.Navigate2(ref o);

}


private void ie_BeforeNavigate(string URL, int Flags, string
TargetFrameName, ref object PostData, string Headers, ref bool Cancel)
{
MessageBox.Show("before nav");
}

private void ie_DownloadComplete()
{

IHTMLDocument2 htmlDocument =
(IHTMLDocument2)axWebBrowser1.Document;
IHTMLElement body = (IHTMLElement)htmlDocument.body;
body.innerHTML = "hello";
body.style.marginTop = 0;
body.style.marginRight= 0;
body.style.marginLeft = 0;
body.style.marginBottom= 0;
MessageBox.Show("download complete");

}
}
}
 
D

DJPoobs

solved this issue now

The cause is mshtml dll is not registered on a machine without visual
studio

to simply fix this create an installation project. The resulting
installation will have the dll in it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top