473,503 Members | 13,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open new IE after closed ERROR!

Hi All, I am trying to open a new instance of IE at the start of my C# application.

When user press Start Recording... My applicaiton will close that specific instance of IE and Open a fresh IE, but if that instance is closed manually, then the App must still be able to open a new fresh IE...

It give me the following erro message:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ieObjTest.exe

Here is my Code.

using SHDocVw;
using System.Diagnostics;

InternetExplorer browser;
protected Process[] processes;
protected Process browserProcess;

public frmSiteAlert()
{
InitializeComponent();

// detect if IE is already running ?
processes = Process.GetProcessesByName("IEXPLORE");

if(processes.Length >= 1)
MessageBox.Show(processes.Length + " Running Copies of internet Explorer has been Detected... ");

// Get the Screen resolution
this.Size = new Size(getScreenWidth(), getScreenHeight()* 30/100);
this.MinimumSize = new Size(200, getScreenHeight()* 30/100);
// Display the form in the top let corner of the screen.
this.StartPosition = FormStartPosition.Manual;
openBrowser();
}

static void Main()
{
Application.Run(new frmSiteAlert());
}

public void openBrowser()
{
browser = new InternetExplorer();
browserProcess = Process.GetCurrentProcess();
if (browser != null)
{
browser.Height = getScreenHeight() *70/100-30;
browser.Width = this.Width;
browser.Top = getScreenHeight()*30/100;
//opened = true;
browser.Visible = true;
object obj = null;
browser.Navigate("about:blank", ref obj, ref obj, ref obj, ref obj);
}

}
// When Start Recording is pressedd
private void miStartRecording_Click(object sender, System.EventArgs e)
{
if(browserProcess.HasExited)
{
openBrowser();
}
else
{
browser.Quit();

/// HERE THE BROGRAM BREAKS !!!!!!!!!!!!!!!

openBrowser();
}
}
private int getScreenWidth()
{
int screenWidth = Screen.PrimaryScreen.Bounds.Width;
return screenWidth;

}
private int getScreenHeight()
{
int screenHeight = Screen.PrimaryScreen.Bounds.Height;
return screenHeight;
}
--------------------------------
Thanks
From: awsok fakry

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>sxzBcSmpoEOc2uL23w9QMg==</Id>
Nov 16 '05 #1
0 1140

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

Similar topics

3
5801
by: Andy Davis | last post by:
How do i or can I open a word document directly from Access? I would like to be able for the user to click a button on my form to open a word document and then also run a macro in Word. Thanks...
1
2558
by: C Sharp beginner | last post by:
I'm sorry about this verbose posting. This is a follow-up to my yesterday's posting. Thanks William for your reply. I understand it is a good practice to open connections as late as possible and...
6
4472
by: karim | last post by:
I have an asp.net page that stopped running properly giving the error below. The app uses a SQL Server 2000 on another server. Enterprise Manager and Query analyzer on the web server can connect to...
5
1638
by: blue | last post by:
We often get connection pooling errors saying that there are no available connections in the pool. I think the problem is that we are passing around open readers all over the place. I am...
15
8251
by: Rob Nicholson | last post by:
I'm starting to worry a bit now. We're getting the above error when two users hit the same database/page on an ASP.NET application using ADO.NET, talking to a SQL 7 server. The error is perfectly...
6
2669
by: ruben | last post by:
Hi: I'm running a large database on PostgreSQL 7.1.3. 20 days ago the database failed with a threatening and not too descriptive error like: pg_exec() query failed: server closed the...
0
2334
by: Seok Bee | last post by:
Dear Experts, In my web application, I'm having a button to view an attachment. After I retrieve the record from database (Ms. Access), I have a button to view the attachment (if there is any)....
6
3520
by: Seok Bee | last post by:
Dear Experts, In my web application, I'm having a button to view an attachment. After I retrieve the record from database (Ms. Access), I have a button to view the attachment (if there is any)....
23
52590
by: PW | last post by:
Hi, I'd like to close a recordset and set the database to nothing if a recordset is open if an error has occured. Leaving a recordset open and a database open isn't a good idea, right? ...
10
6086
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the...
0
7213
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
7098
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
7366
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
7471
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...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.