473,385 Members | 1,676 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,385 software developers and data experts.

Excel process remains in memory after ASP.NET automation.

Hi,

I have a routine which is call from a ASP.NET web form. This routine creates
an excel application, opens a workbook , runs some code to update the
workbook, saves it as HTML on the sever and returns to the Web form to
display.

All is OK, except EXCEL remains in the process list in task manager.
I am following all guideline in releasing the com components.

Regards
Tim

Nov 18 '05 #1
11 2212
I'm assuming you mean its running on the server and not client?
and could you show how you release this component and call it.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Tim Marsden" <TM@UK.COM> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a routine which is call from a ASP.NET web form. This routine creates an excel application, opens a workbook , runs some code to update the
workbook, saves it as HTML on the sever and returns to the Web form to
display.

All is OK, except EXCEL remains in the process list in task manager.
I am following all guideline in releasing the com components.

Regards
Tim

Nov 18 '05 #2
Many thanks for reply.

Yes, you are correct it is on the server, I am aware of the licensing issues
and lack of support from Microsoft.

Code section

Dim objExcelApplication As Excel.Application
Dim objWorkbook As Excel.Workbook
Dim objWorkbooks As Excel.Workbooks
Dim objWorksheets As Excel.Worksheets
Dim objWorksheet As Excel.Worksheet
Dim dsExcelMenu As rdsExcelMenu

Try

Try
objExcelApplication = New Excel.Application

objExcelApplication.Visible = False
objExcelApplication.DisplayAlerts = False

Catch ex As Exception
'>>> Excel Error
Throw ex
End Try

Try
objWorkbooks = objExcelApplication.Workbooks
objWorkbooks.Open(strWorkbook, False, True)
objWorkbook = objWorkbooks.Item(1)
Catch ex As Exception
'>>> Workbook Open Error
Throw ex
End Try

** process here etc

Catch ex As Exception
Throw ex
Finally
If Not objWorksheet Is Nothing Then
ReleaseComObject(objWorksheet)
End If
If Not objWorksheets Is Nothing Then
ReleaseComObject(objWorksheets)
End If
If Not objWorkbook Is Nothing Then
objWorkbook.Close(False)
ReleaseComObject(objWorkbook)
End If
If Not objWorkbooks Is Nothing Then
ReleaseComObject(objWorkbooks)
End If
If Not objExcelApplication Is Nothing Then
objExcelApplication.Quit()
ReleaseComObject(objExcelApplication)
End If
GC.Collect()
GC.WaitForPendingFinalizers()

End Try
'================================================= ===============
Private Sub ReleaseComObject(ByRef Reference As Object)
Try
Do Until
System.Runtime.InteropServices.Marshal.ReleaseComO bject(Reference) <= 0
Loop
Catch
Finally
Reference = Nothing
GC.Collect()
End Try
End Sub
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:eP**************@TK2MSFTNGP10.phx.gbl...
I'm assuming you mean its running on the server and not client?
and could you show how you release this component and call it.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Tim Marsden" <TM@UK.COM> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a routine which is call from a ASP.NET web form. This routine

creates
an excel application, opens a workbook , runs some code to update the
workbook, saves it as HTML on the sever and returns to the Web form to
display.

All is OK, except EXCEL remains in the process list in task manager.
I am following all guideline in releasing the com components.

Regards
Tim


Nov 18 '05 #3
this is expected behavior. you will have to add code to kill the process if
you want it to go away.

-- bruce (sqlwork.com)
"Tim Marsden" <TM@UK.COM> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a routine which is call from a ASP.NET web form. This routine creates an excel application, opens a workbook , runs some code to update the
workbook, saves it as HTML on the sever and returns to the Web form to
display.

All is OK, except EXCEL remains in the process list in task manager.
I am following all guideline in releasing the com components.

Regards
Tim

Nov 18 '05 #4
I'm inclined to agree that this would be "expected" behavior - if you've paid your dues and discovered it through trial-and-error. But it seems like Tim Marsden read MS doccumentation and "expected" things to work as advertised

What you are saying makes sense. Setting the application object to nothing doesn't seem to get the job done. You have to kill the process. Got any sample code?
Nov 18 '05 #5
Thanks for your thoughts

I can kill a process easily, but how do I identify the Excel process which
was started by my app, and not other running Excel processes.

Tim

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I'm inclined to agree that this would be "expected" behavior - if you've paid your dues and discovered it through trial-and-error. But it seems like
Tim Marsden read MS doccumentation and "expected" things to work as
advertised.
What you are saying makes sense. Setting the application object to

nothing doesn't seem to get the job done. You have to kill the process.
Got any sample code?
Nov 18 '05 #6
How many instances of Excel are you planning on having running at the same
time on your server? Hint: your server will likely choke on more than one.
You may have noticed that even a single instance of Excel runs rather
slugishly on a web server.
Read this article if you haven't already:
http://www.aspnetpro.com/NewsletterA...200309so_l.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Tim Marsden" <TM@UK.COM> wrote in message
news:Om**************@TK2MSFTNGP11.phx.gbl...
Thanks for your thoughts

I can kill a process easily, but how do I identify the Excel process which
was started by my app, and not other running Excel processes.

Tim

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I'm inclined to agree that this would be "expected" behavior - if you've paid your dues and discovered it through trial-and-error. But it seems

like Tim Marsden read MS doccumentation and "expected" things to work as
advertised.

What you are saying makes sense. Setting the application object to

nothing doesn't seem to get the job done. You have to kill the process.
Got any sample code?

Nov 18 '05 #7
Hi

Thanks Steve, I have read your excellent article and it very enlightening

I have realised the problems with Excel.
I am now planning on moving the Excel processing one to another dedicated
machine. With queuing and first come first served type basis, I just need to
work out the mechanisms.
If anyone has ideas on how I can achieve this I would be grateful.
I have gone to far down this path to abandon the idea. (client request).
My app is primarily local excel based, however I need a way of serving over
the intranet.

Regards
Tim

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uA**************@TK2MSFTNGP11.phx.gbl...
How many instances of Excel are you planning on having running at the same
time on your server? Hint: your server will likely choke on more than one. You may have noticed that even a single instance of Excel runs rather
slugishly on a web server.
Read this article if you haven't already:
http://www.aspnetpro.com/NewsletterA...200309so_l.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Tim Marsden" <TM@UK.COM> wrote in message
news:Om**************@TK2MSFTNGP11.phx.gbl...
Thanks for your thoughts

I can kill a process easily, but how do I identify the Excel process which was started by my app, and not other running Excel processes.

Tim

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I'm inclined to agree that this would be "expected" behavior - if
you've paid your dues and discovered it through trial-and-error. But it seems

like
Tim Marsden read MS doccumentation and "expected" things to work as
advertised.

What you are saying makes sense. Setting the application object to

nothing doesn't seem to get the job done. You have to kill the process.
Got any sample code?


Nov 18 '05 #8
You can use System.Runtime.InteropServices.Marshal.ReleaseComO bject(xxx) for
each excel object that you work with, i.e. ranges, worksheets, workbooks,
and the excel app itself. After that, set each of the objects to Nothing.
When this is done, you can call GC.Collect, followed by
GC.WaitForPendingFinalizers().

The docs say never to call GC.Collect, but it will free the 25 MB + of
memory excel is using, so its ok. Excel was never meant to be used as a
server side app, and there are 3rd party products you can buy that will
perform better.

Hope this helps.

--
Eric Marvets
Principal Consultant

the bang project

<shameless self promotion>

Email sa*********@bangREMOVETHISproject.com for Information on Our
Architecture and Mentoring Services

</shameless self promotion>
Nov 18 '05 #9
Thanks Eric

As your can see from my early post, I am doing the steps you recommend, but
the Excel is still resident.
I will try a different approach. Thanks for your time.

Regards
Tim
"Eric Marvets" <er*********@bangREMOVETHISproject.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You can use System.Runtime.InteropServices.Marshal.ReleaseComO bject(xxx) for each excel object that you work with, i.e. ranges, worksheets, workbooks,
and the excel app itself. After that, set each of the objects to Nothing.
When this is done, you can call GC.Collect, followed by
GC.WaitForPendingFinalizers().

The docs say never to call GC.Collect, but it will free the 25 MB + of
memory excel is using, so its ok. Excel was never meant to be used as a
server side app, and there are 3rd party products you can buy that will
perform better.

Hope this helps.

--
Eric Marvets
Principal Consultant

the bang project

<shameless self promotion>

Email sa*********@bangREMOVETHISproject.com for Information on Our
Architecture and Mentoring Services

</shameless self promotion>

Nov 18 '05 #10
Hi Tim,

Does the same problem occur if you run Steven's Article's automation code?
I've run it and the serverside excel process is successfully released. So I
think you can try some any style code to see whether this is an expected
result. Are you running the code with impersontating a powerful account
such as administrator, this is also a possible cause. Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #11
Hi Tim,

Have you got any further ideas on this issue? If you have anything unclear
or if there're anything else we can help, please feel free to post here.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #12

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

Similar topics

7
by: taylor.bryant | last post by:
I am running: Win XP SP2 Excel 2002, Access 2002 (Office XP SP3) Using Visual Basic (not VB.NET) At one point (prior to XP SP2?!? - I can't pin it down), this did not happen and I was easily...
3
by: Stephen Brooker | last post by:
Hi all, Just playing around a MS how-to sample to work with an Excel file from within C#. Everything is fine and I understand it OK, however when Excel and the application are closed, there is...
2
by: Praveen K | last post by:
I have a problem in communicating between the C# and the Excel Interop objects. The problem is something as described below. I use Microsoft Office-XP PIA dll’s as these dll’s were been...
6
by: Steve Richter | last post by:
I am getting error in a vbscript: ActiveX component cant create object: Excel.Application. The vbscript code is: Dim objExcel Set objExcel = CreateObject("Excel.Application") I am pretty...
12
by: elziko | last post by:
I'm using late binding (I must) to automate Excel. My code opens Excel after createing and poulating some sheets. My problem is that when the user finally decides to close Excel its process is...
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...
1
by: myname | last post by:
Hello, in VB.Net, I use Excel to display results : dim xl as new Excel.Application // creates an Excel process // snip (putting values into cells) xl.Visible = true If the user closes the...
2
by: Brandon | last post by:
Hi all, I'm currently working on a project where we have a need to expose an Excel spreadsheet on the web as a webservice that needs to be reliable and available 24x7x365. I've implemented a...
7
by: =?Utf-8?B?VGVycnkgSG9sbGFuZA==?= | last post by:
I have a vb.net app that opens an excel worksheet, reads data and then closes the sheet. Im noticing that the Excel process is still running after I have closed and disposed of my excel objects. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.