472,353 Members | 1,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

ExecutionEngineException using AxSHDocVw.AxWebBrowser

Hi,

In my c# windows application, i am using AxSHDocVw.AxWebBrowser.
I am displaying a generated receipt html in this browser. Also,
for printing the same html, i am using the following command :

axWebBrowser2.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER ,ref empty,ref
empty);

This works fine and Html is printed properly on some machines.
But on some machines, it is giving ExecutionEngineException or
sometimes
it is giving StackOverflowExceptions. Since as per the microsoft site,

we cannot catch these both types of exceptions at all.
Also, i cannot debug the occured exception, because it is occuring
only on client machines.

Can anyone pls help me to solve this problem?

Thanks & Regards,
Sagaraj

Here is the entire code :
-----------------------------------

using System;
using System.Drawing;
using System.Data;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;
using System.Diagnostics;

public class FrmPaymentReceipt : System.Windows.Forms.Form
{
public const string YES = "Y";
public const string NO = "N";
public const int PERCENTAGE=100;
private PaymentReceiptDS paymentReceiptDS;
ulong subTotal = 0;
float tax=0;
decimal saleAmount=0;
decimal returnAmount=0;
decimal saleAmt_Minus_ReturnAmt=0;
private AxSHDocVw.AxWebBrowser axWebBrowser2;
private XmlDocument xmlDoc;
bool printFlag=true;

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

this.Visible = false;

}

public FrmPaymentReceipt(PaymentReceiptDS paymentReceiptDS,
bool printFlag)
{
//
// Required for Windows Form Designer support
//
this.Visible = false;
InitializeComponent();
this.paymentReceiptDS = paymentReceiptDS;
this.printFlag = printFlag;
this.Visible = false;
}

/// <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(FrmPayment Receipt));
this.axWebBrowser2 = new AxSHDocVw.AxWebBrowser();
((System.ComponentModel.ISupportInitialize)(this.a xWebBrowser2)).BeginInit();
this.SuspendLayout();
//
// axWebBrowser2
//
this.axWebBrowser2.Enabled = true;
this.axWebBrowser2.Location = new System.Drawing.Point(88, 148);
this.axWebBrowser2.OcxState =
((System.Windows.Forms.AxHost.State)(resources.Get Object("axWebBrowser2.OcxState")));
this.axWebBrowser2.Size = new System.Drawing.Size(300, 150);
this.axWebBrowser2.TabIndex = 1;
this.axWebBrowser2.Visible = false;
//
// FrmPaymentReceipt
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
this.ClientSize = new System.Drawing.Size(720, 448);
this.ControlBox = false;
this.Controls.Add(this.axWebBrowser2);
this.Name = "FrmPaymentReceipt";
this.Load += new System.EventHandler(this.FrmPaymentReceipt_Load);
this.Activated += new
System.EventHandler(this.FrmPaymentReceipt_Activat ed);
((System.ComponentModel.ISupportInitialize)(this.a xWebBrowser2)).EndInit();
this.ResumeLayout(false);

}
#endregion

private void FrmPaymentReceipt_Load(object sender, System.EventArgs e)
{
this.Visible = false;
this.CalculateBalance();
this.ArticleSaleReturnAmount();
string xmlSchema = this.paymentReceiptDS.GetXml();
this.Visible = false;
xmlSchema =
xmlSchema.Replace("xmlns=\"http://tempuri.org/ReceiptDS.xsd\"","");
this.Visible = false;
xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlSchema);
this.Visible = false;
XmlTextWriter writer =
new XmlTextWriter("receipt.xml",System.Text.Encoding.U TF8);
writer.WriteStartDocument(true);
this.Visible = false;
writer.WriteProcessingInstruction("xml-stylesheet",
"type=\"text/xsl\" href=\"receipt.xsl\"");
writer.WriteRaw(xmlSchema);
writer.Close();
xmlDoc.CreateProcessingInstruction("xml-stylesheet",
"type=\"text/xsl\" href=\"receipt.xsl\"");
this.Visible = false;
this.InitializeReport();
this.Visible = false;
}

private void InitializeReport()
{
this.Visible = false;
string strxslName = "receipt.xsl";

if (this.paymentReceiptDS.RETURN_PARTICULARS.Rows.Cou nt<=0)
{
}
else
{
strxslName = "receiptreturn.xsl";
}

StringWriter sw;
sw = MergeXSL_XML("receipt.xml",strxslName);
System.IO.StreamWriter file =
new System.IO.StreamWriter("receipt.html");
file.WriteLine(sw.ToString());
file.Close();

object empty = System.Reflection.Missing.Value;
axWebBrowser2.Navigate("about:blank",ref empty,ref empty,
ref empty,ref empty);
mshtml.IHTMLDocument2 htmlDoc =
(mshtml.IHTMLDocument2) axWebBrowser2.Document;
htmlDoc.writeln(sw.ToString());

this.Visible = false;
Object a = new object(),b = new object();

if(System.Configuration.ConfigurationSettings.AppS ettings["ExecutionMode"]!="Testing")
{
if (printFlag)
{
axWebBrowser2.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER ,
ref empty,ref empty );
axWebBrowser2.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER ,
ref empty,ref empty );
}
}
this.Visible = false;
}

public StringWriter MergeXSL_XML(string xml, string xsl)
{
try
{
//XPathDocument xPath = new XPathDocument(xml);

XslTransform xTrans = new XslTransform();
xTrans.Load(Application.StartupPath+ "\\"+ xsl);
StringWriter strW = new StringWriter();
xTrans.Transform(xmlDoc,null,strW);
strW.Close();
return strW;
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
return null;
}
}

Apr 13 '06 #1
0 1922

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Elliott | last post by:
I have created an application that loads assemblies (plugins). These plugins are windows forms that have an embedded browser. private...
3
by: Simon CJC | last post by:
Hello I use AxSHDocVw.AxWebBrowser in a windows application. But sometimes the url I browsed in AxSHDocVw.AxWebBrowser contains error caused by...
1
by: Pengyu | last post by:
I host AxSHDocVw.AxWebBrowser in my C# application. It generally works ok. However, the AxSHDocVw.AxWebBrowser control sometime stucks and can not...
0
by: Mystery Man | last post by:
Currently, we use host AxSHDocVw.AxWebBrowser as an HTML editor. There are two questions I have with this control: (1) When the user presses...
0
by: Manuel Costa | last post by:
Hi i want to restrict the AxSHDocVw.AxWebBrowser to html pages. For example, when clicked, links to files by http or ftp should be canceled. ...
1
by: jokolee | last post by:
i was using component AxSHDocVw.AxWebBrowser,,but i rather confuces because when i write AxWebBrowser1.Document. the next option is Gettype...
2
by: Fredo | last post by:
I'm going to try to post this without having to paste in hundreds of lines of code. I'm trying to override IInternetSecurityManager. I'm taking...
4
by: =?Utf-8?B?RGF2ZSBF?= | last post by:
I have written an application that reads third party web pages. If I am using HTTP everything works fine. I create an AxSHDocVw.AxWebBrowser...
1
by: tim2006 | last post by:
When i try to run the program, it just hangs. If i remove the axwebbrowser control it works fine. Any ideas? Here is my code: class1.vb ...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.