473,395 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 2024

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 AxSHDocVw.AxWebBrowser browser; If I comment out...
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 javascript. Can I prevent javascript from running in...
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 nevigate to other URLs. What is the problem? BTW,...
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 the ENTER key it creates a new paragraph and as a...
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. manuel
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 function,,,nothing else...... But when i write...
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 sort of a minimalist approach and adding code as I...
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 object and then Navigate2 to the page. I then...
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 Imports System.Windows.Forms Imports...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.