473,405 Members | 2,141 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,405 software developers and data experts.

cannot kill excel process

Hi everyone,

I am trying to include one feature using excel object in my application.

I am giving the code to create and kill the process , that i got from
Microsoft site.......but nothing is happening

it will create one process but , it wont close . i used the code from the
link below:

http://www.dotnet247.com/247referenc...m/?kbid=317109

How can i kill the process?

Also will this work in Windows server 2003

// function

private void NAR(object o)

{

try

{

System.Runtime.InteropServices.Marshal.ReleaseComO bject(o);

}

catch {}

finally

{

o = null;

}

}

// button click

private void Button1_Click(object sender, System.EventArgs e)

{
PIA.ApplicationClass excelApplication = new PIA.ApplicationClass();

PIA.Workbook excelWorkbook =
((PIA.Workbook)excelApplication.Workbooks.Add(Syst em.Reflection.Missing.Value));

PIA.Worksheet excelSheet = ((PIA.Worksheet)(excelWorkbook.ActiveSheet));

NAR(excelSheet);

excelWorkbook.Close(false,null,null);

NAR(excelWorkbook);

excelApplication.Quit();

NAR(excelApplication);
Debug.WriteLine("Sleeping...");

System.Threading.Thread.Sleep(1000);

Debug.WriteLine("End Excel");

GC.Collect();

GC.WaitForPendingFinalizers();
}

thanks & regards

charmis




Nov 19 '05 #1
2 4845
"charmis" <ch*****@hotmail.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
Hi everyone,

I am trying to include one feature using excel object in my application.

I am giving the code to create and kill the process , that i got from
Microsoft site.......but nothing is happening

it will create one process but , it wont close . i used the code from the
link below:

http://www.dotnet247.com/247referenc...m/?kbid=317109

Don't use that example, it is for client-side code. It is a bad practice to
use Office objects in server-side code:
http://support.microsoft.com/kb/257757

Find an alternate way to do what you need.
Nov 19 '05 #2
After releasing Com Object, force Garbage Collection, you
will kill EXCEL process immediately:

exBook.Close();
app.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComO bject
(app);
GC.Collect();

Elton Wang
el********@hotmail.com
-----Original Message-----
Hi everyone,

I am trying to include one feature using excel object in my application.
I am giving the code to create and kill the process , that i got fromMicrosoft site.......but nothing is happening

it will create one process but , it wont close . i used the code from thelink below:

http://www.dotnet247.com/247reference/a.aspx? u=http://support.microsoft.com/?kbid=317109
How can i kill the process?

Also will this work in Windows server 2003

// function

private void NAR(object o)

{

try

{

System.Runtime.InteropServices.Marshal.ReleaseCom Object (o);
}

catch {}

finally

{

o = null;

}

}

// button click

private void Button1_Click(object sender, System.EventArgs e)
{
PIA.ApplicationClass excelApplication = new PIA.ApplicationClass();
PIA.Workbook excelWorkbook =
((PIA.Workbook)excelApplication.Workbooks.Add (System.Reflection.Missing.Value));
PIA.Worksheet excelSheet = ((PIA.Worksheet) (excelWorkbook.ActiveSheet));
NAR(excelSheet);

excelWorkbook.Close(false,null,null);

NAR(excelWorkbook);

excelApplication.Quit();

NAR(excelApplication);
Debug.WriteLine("Sleeping...");

System.Threading.Thread.Sleep(1000);

Debug.WriteLine("End Excel");

GC.Collect();

GC.WaitForPendingFinalizers();
}

thanks & regards

charmis




.

Nov 19 '05 #3

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

Similar topics

5
by: Josema | last post by:
Hi to all, I have a windows application that uses workbooks, sheets, ranges, etc... This application is consumed by few clients. Some weeks ago I had problems to kill excel.exe process but i...
3
by: hari krishna | last post by:
hi, I am generating excel reports through vb.Net. After creating excel.application and the report is generated, each report leaves Excel in memory. I can see them in task manager in Process tab...
1
by: Michael Tkachev | last post by:
Hi Everybody, I created an Excel file in the ASP.Net. When I wrote this file on the disk I tryed to release COM objects. But I couldn't do it. When my method finished an "Excel" process exists...
1
by: Lee Gillie | last post by:
I need to be able to kill a process programmatically under ASP.NET. IIS runs under the local system account. The user accessing the web is using anonymous access. We would prefer NOT to grant...
2
by: touf | last post by:
Hi, I use the folowing code to create a new Excel file using a query It creates an excel file and save it on the disc, but When I double-clic on it (explorer) it open Excel and bloc,(don't display...
0
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a...
3
by: Agnes | last post by:
Dim dsExcelExport As New System.Data.DataSet Dim daExcelExport As New System.Data.SqlClient.SqlDataAdapter Dim Excel As New Excel.Application Dim strExcelFile As String Dim strFileName As...
2
by: ChrisFrohlich | last post by:
I have been trying to use the Office PIA's to write an ASP.NEt page to: 1. Open a template workbook 2. Populate some data 3. Save the file back to the server 4. Quit Excel and free up Memory I...
2
by: alexia.bee | last post by:
Hi All, I need to get all the IDs of specific process and kill all the instances of that process. Something like: // theArray get all the Excel proc IDs in the Task manager string theArray...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.