469,607 Members | 1,889 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

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 1831

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Pengyu | last post: by
reply views Thread by Mystery Man | last post: by
4 posts views Thread by =?Utf-8?B?RGF2ZSBF?= | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.