Hi!
This issue have been discussed a lot, but I haven't found a solution that
applies to ASP.NET. I have a library which does some operations on Excel
documents, and it will be used in an ASP.NET application. If I use the
library in a Forms application, the Excel process is removed when the
cleanup operations are done, but with ASP.NET all possible ways to clean up
fails.
The following code has been tried:
Application app = new ApplicationClas s();
Workbook wb = null;
// some code... no sheet reference done, only doing wb.load, x =
wb.Worksheets.C ount, wb.close
// release workbook
ReleaseComObjec t(wb);
wb = null;
app.Quit();
ReleaseComObjec t(app);
app = null;
When the method is called from a windows app, Excel is now gone, but when
called from ASP.NET the Excel process remains.
So we gathered that the process had to be killed manually. Off to the Win32
api to find some functions. Et voila, we find GetWindowThread ProcessId. But
what do you know? When the method is called from a windows app, the process
ID is filled and we can kill the process, but when called from ASP.NET, the
process ID is 0, the thread ID is 0, and Excel is still lingering about..
I for one am ready to be committed to the local asylum...
Any help greatly appreciated.... ..
Lars-Erik 10 3072
Hi,
try System.GC.Colle ct to cleanup all COM objects forcefully after you
finished off using them.
HTH
Regards
Joyjit
"Lars-Erik Aabech" <la************ **@markedspartn er.noSPAMBLOCK> wrote in
message news:OQ******** ******@tk2msftn gp13.phx.gbl... Hi!
This issue have been discussed a lot, but I haven't found a solution that applies to ASP.NET. I have a library which does some operations on Excel documents, and it will be used in an ASP.NET application. If I use the library in a Forms application, the Excel process is removed when the cleanup operations are done, but with ASP.NET all possible ways to clean
up fails.
The following code has been tried:
Application app = new ApplicationClas s(); Workbook wb = null;
// some code... no sheet reference done, only doing wb.load, x = wb.Worksheets.C ount, wb.close
// release workbook ReleaseComObjec t(wb); wb = null;
app.Quit(); ReleaseComObjec t(app); app = null;
When the method is called from a windows app, Excel is now gone, but when called from ASP.NET the Excel process remains.
So we gathered that the process had to be killed manually. Off to the
Win32 api to find some functions. Et voila, we find GetWindowThread ProcessId.
But what do you know? When the method is called from a windows app, the
process ID is filled and we can kill the process, but when called from ASP.NET,
the process ID is 0, the thread ID is 0, and Excel is still lingering about..
I for one am ready to be committed to the local asylum...
Any help greatly appreciated.... ..
Lars-Erik
I did. Forgot to include it in the sample code.
Also tried GC.WaitForPendi ngFinalizers().
Still no cigar...
L-E
"Joyjit Mukherjee" <jo************ **@hotmail.com> wrote in message
news:e6******** ******@TK2MSFTN GP12.phx.gbl... Hi,
try System.GC.Colle ct to cleanup all COM objects forcefully after you finished off using them.
HTH Regards Joyjit
"Lars-Erik Aabech" <la************ **@markedspartn er.noSPAMBLOCK> wrote in message news:OQ******** ******@tk2msftn gp13.phx.gbl... Hi!
This issue have been discussed a lot, but I haven't found a solution
that applies to ASP.NET. I have a library which does some operations on Excel documents, and it will be used in an ASP.NET application. If I use the library in a Forms application, the Excel process is removed when the cleanup operations are done, but with ASP.NET all possible ways to clean up fails.
The following code has been tried:
Application app = new ApplicationClas s(); Workbook wb = null;
// some code... no sheet reference done, only doing wb.load, x = wb.Worksheets.C ount, wb.close
// release workbook ReleaseComObjec t(wb); wb = null;
app.Quit(); ReleaseComObjec t(app); app = null;
When the method is called from a windows app, Excel is now gone, but
when called from ASP.NET the Excel process remains.
So we gathered that the process had to be killed manually. Off to the Win32 api to find some functions. Et voila, we find GetWindowThread ProcessId. But what do you know? When the method is called from a windows app, the process ID is filled and we can kill the process, but when called from ASP.NET, the process ID is 0, the thread ID is 0, and Excel is still lingering
about.. I for one am ready to be committed to the local asylum...
Any help greatly appreciated.... ..
Lars-Erik
microsoft does not recommend this approach: http://support.microsoft.com/default...b;EN-US;257757
here is the workaround to do the exit http://support.microsoft.com/default...b;EN-US;317109
-- bruce (sqlwork.com)
"Lars-Erik Aabech" <la************ **@markedspartn er.noSPAMBLOCK> wrote in
message news:OQ******** ******@tk2msftn gp13.phx.gbl... Hi!
This issue have been discussed a lot, but I haven't found a solution that applies to ASP.NET. I have a library which does some operations on Excel documents, and it will be used in an ASP.NET application. If I use the library in a Forms application, the Excel process is removed when the cleanup operations are done, but with ASP.NET all possible ways to clean
up fails.
The following code has been tried:
Application app = new ApplicationClas s(); Workbook wb = null;
// some code... no sheet reference done, only doing wb.load, x = wb.Worksheets.C ount, wb.close
// release workbook ReleaseComObjec t(wb); wb = null;
app.Quit(); ReleaseComObjec t(app); app = null;
When the method is called from a windows app, Excel is now gone, but when called from ASP.NET the Excel process remains.
So we gathered that the process had to be killed manually. Off to the
Win32 api to find some functions. Et voila, we find GetWindowThread ProcessId.
But what do you know? When the method is called from a windows app, the
process ID is filled and we can kill the process, but when called from ASP.NET,
the process ID is 0, the thread ID is 0, and Excel is still lingering about..
I for one am ready to be committed to the local asylum...
Any help greatly appreciated.... ..
Lars-Erik
I've tried all the workarounds. As you can see from my previous posts, the
..Net client releases excel when ran as a windows application or service.
Only when ran as ASP.NET Excel will stay around. Might be that I have to
create and release a reference to Worksheets too though, but I've allready
rewritten the code to use ADO for this problem. Anyway, thanks for the help
ppl - hope this issue will be resolved for office 2005 ;)
Lars-Erik
"bruce barker" <no***********@ safeco.com> wrote in message
news:Os******** ******@tk2msftn gp13.phx.gbl... microsoft does not recommend this approach:
http://support.microsoft.com/default...b;EN-US;257757
here is the workaround to do the exit
http://support.microsoft.com/default...b;EN-US;317109 -- bruce (sqlwork.com)
"Lars-Erik Aabech" <la************ **@markedspartn er.noSPAMBLOCK> wrote in message news:OQ******** ******@tk2msftn gp13.phx.gbl... Hi!
This issue have been discussed a lot, but I haven't found a solution
that applies to ASP.NET. I have a library which does some operations on Excel documents, and it will be used in an ASP.NET application. If I use the library in a Forms application, the Excel process is removed when the cleanup operations are done, but with ASP.NET all possible ways to clean up fails.
The following code has been tried:
Application app = new ApplicationClas s(); Workbook wb = null;
// some code... no sheet reference done, only doing wb.load, x = wb.Worksheets.C ount, wb.close
// release workbook ReleaseComObjec t(wb); wb = null;
app.Quit(); ReleaseComObjec t(app); app = null;
When the method is called from a windows app, Excel is now gone, but
when called from ASP.NET the Excel process remains.
So we gathered that the process had to be killed manually. Off to the Win32 api to find some functions. Et voila, we find GetWindowThread ProcessId. But what do you know? When the method is called from a windows app, the process ID is filled and we can kill the process, but when called from ASP.NET, the process ID is 0, the thread ID is 0, and Excel is still lingering
about.. I for one am ready to be committed to the local asylum...
Any help greatly appreciated.... ..
Lars-Erik
Ever get this to work?
Having the exact same issue.
Excel continues to run, even after releasing the coms, and when I try
and get the process ID I am rewarded with a 0.
Lars-Erik Aabech wrote: I've tried all the workarounds. As you can see from my previous
posts, the .Net client releases excel when ran as a windows application or
service. Only when ran as ASP.NET Excel will stay around. Might be that I have
to create and release a reference to Worksheets too though, but I've
allready rewritten the code to use ADO for this problem. Anyway, thanks for
the help ppl - hope this issue will be resolved for office 2005 ;)
Lars-Erik
"bruce barker" <no***********@ safeco.com> wrote in message news:Os******** ******@tk2msftn gp13.phx.gbl... microsoft does not recommend this approach:
http://support.microsoft.com/default...b;EN-US;257757
here is the workaround to do the exit
http://support.microsoft.com/default...b;EN-US;317109 -- bruce (sqlwork.com)
"Lars-Erik Aabech" <la************ **@markedspartn er.noSPAMBLOCK>
wrote in message news:OQ******** ******@tk2msftn gp13.phx.gbl... Hi!
This issue have been discussed a lot, but I haven't found a
solution that applies to ASP.NET. I have a library which does some operations
on Excel documents, and it will be used in an ASP.NET application. If I
use the library in a Forms application, the Excel process is removed when
the cleanup operations are done, but with ASP.NET all possible ways
to clean up fails.
The following code has been tried:
Application app = new ApplicationClas s(); Workbook wb = null;
// some code... no sheet reference done, only doing wb.load, x = wb.Worksheets.C ount, wb.close
// release workbook ReleaseComObjec t(wb); wb = null;
app.Quit(); ReleaseComObjec t(app); app = null;
When the method is called from a windows app, Excel is now gone,
but when called from ASP.NET the Excel process remains.
So we gathered that the process had to be killed manually. Off to
the Win32 api to find some functions. Et voila, we find
GetWindowThread ProcessId. But what do you know? When the method is called from a windows app,
the process ID is filled and we can kill the process, but when called from
ASP.NET, the process ID is 0, the thread ID is 0, and Excel is still lingering about.. I for one am ready to be committed to the local asylum...
Any help greatly appreciated.... ..
Lars-Erik
Here is a code snippit of what I am trying to do. In general I am doing
the following.
1. creating an excel object
2. loading an xls file into the object
3. reading a value from the file and then updating a value in the file.
4. saving and closing the file.
5. quiting the excel object.
6. attempting to determine the Process ID of the hanging Excel object and
then terminate it. So far I only get a ProcessID of Zero, however.
*************** ********
Dim xExcel As New Excel.Applicati on
Dim xBook As Object
Dim xBooks As Object
Dim xSheets As Object
Dim xSheet As Object
Dim xRange As Object
xBooks = xExcel.Workbook s
xBook = xBooks.Open(Fil ename:=strExcel File, UpdateLinks:=Fa lse,
ReadOnly:=False )
Dim objPtr As New IntPtr
Dim intID As Integer = 0
Dim i As Integer = 0
objPtr = New System.IntPtr(x Excel.Hwnd)
i = GetWindowThread ProcessId(objPt r, intID)
If intID > 0 Then
Dim pExcel As New System.Diagnost ics.Process
pExcel = System.Diagnost ics.Process.Get ProcessById(int ID)
pExcel.Kill()
End If
Run....Run fast!
If you look at Microsoft's web site, they strongly discourage anyone from
using office applications from inside of asp.net. If there is any way
around it, then do it. One option would be to use Sql Reporting Services to
create a report and then export that report to an Excel file (file stream
you send back to the client).
"abillmeier " <ab********@ldm kusa.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . Ever get this to work? Having the exact same issue. Excel continues to run, even after releasing the coms, and when I try and get the process ID I am rewarded with a 0.
Lars-Erik Aabech wrote: I've tried all the workarounds. As you can see from my previous posts, the .Net client releases excel when ran as a windows application or service. Only when ran as ASP.NET Excel will stay around. Might be that I have to create and release a reference to Worksheets too though, but I've allready rewritten the code to use ADO for this problem. Anyway, thanks for the help ppl - hope this issue will be resolved for office 2005 ;)
Lars-Erik
"bruce barker" <no***********@ safeco.com> wrote in message news:Os******** ******@tk2msftn gp13.phx.gbl... microsoft does not recommend this approach:
http://support.microsoft.com/default...b;EN-US;257757
here is the workaround to do the exit
http://support.microsoft.com/default...b;EN-US;317109 -- bruce (sqlwork.com)
"Lars-Erik Aabech" <la************ **@markedspartn er.noSPAMBLOCK> wrote in message news:OQ******** ******@tk2msftn gp13.phx.gbl... > Hi! > > This issue have been discussed a lot, but I haven't found a solution that > applies to ASP.NET. I have a library which does some operations on Excel > documents, and it will be used in an ASP.NET application. If I use the > library in a Forms application, the Excel process is removed when the > cleanup operations are done, but with ASP.NET all possible ways to clean up > fails. > > The following code has been tried: > > Application app = new ApplicationClas s(); > Workbook wb = null; > > // some code... no sheet reference done, only doing wb.load, x = > wb.Worksheets.C ount, wb.close > > // release workbook > ReleaseComObjec t(wb); > wb = null; > > app.Quit(); > ReleaseComObjec t(app); > app = null; > > When the method is called from a windows app, Excel is now gone, but when > called from ASP.NET the Excel process remains. > > So we gathered that the process had to be killed manually. Off to the Win32 > api to find some functions. Et voila, we find GetWindowThread ProcessId. But > what do you know? When the method is called from a windows app, the process > ID is filled and we can kill the process, but when called from ASP.NET, the > process ID is 0, the thread ID is 0, and Excel is still lingering about.. > > I for one am ready to be committed to the local asylum... > > Any help greatly appreciated.... .. > > Lars-Erik > >
Yeah. I know it is STRONGLY discouraged, but it is a request from above and
I need to find out if/how to do it regardless of the warnings.
In theory the code should work. I know it's not elegant.
The Excel part works great, except for leaving a hanging process. After
trying all of the MS reccomendations , I figured it might be best to just
identify the process ID of the hanger and then outright kill it. It is the
identification of the process ID that I am having a problem with at the
moment as it always comes back 0.
Any idea what is wrong?
Are there permissions retrictions that would stop the page from lookingup a
process id. Are there permission restrictions that will also stop me from
killing a process that was started by the page?
"David Jessee" <dj*****@housto n.rr.com> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l... Run....Run fast!
If you look at Microsoft's web site, they strongly discourage anyone from using office applications from inside of asp.net. If there is any way around it, then do it. One option would be to use Sql Reporting Services to create a report and then export that report to an Excel file (file stream you send back to the client).
"abillmeier " <ab********@ldm kusa.com> wrote in message news:11******** **************@ f14g2000cwb.goo glegroups.com.. . Ever get this to work? Having the exact same issue. Excel continues to run, even after releasing the coms, and when I try and get the process ID I am rewarded with a 0.
Lars-Erik Aabech wrote: > I've tried all the workarounds. As you can see from my previous posts, the > .Net client releases excel when ran as a windows application or service. > Only when ran as ASP.NET Excel will stay around. Might be that I have to > create and release a reference to Worksheets too though, but I've allready > rewritten the code to use ADO for this problem. Anyway, thanks for the help > ppl - hope this issue will be resolved for office 2005 ;) > > Lars-Erik > > > "bruce barker" <no***********@ safeco.com> wrote in message > news:Os******** ******@tk2msftn gp13.phx.gbl... > > microsoft does not recommend this approach: > > > > http://support.microsoft.com/default...b;EN-US;257757 > > > > here is the workaround to do the exit > > > > http://support.microsoft.com/default...b;EN-US;317109 > > > > > > > > -- bruce (sqlwork.com) > > > > > > "Lars-Erik Aabech" <la************ **@markedspartn er.noSPAMBLOCK> wrote in > > message news:OQ******** ******@tk2msftn gp13.phx.gbl... > > > Hi! > > > > > > This issue have been discussed a lot, but I haven't found a solution > that > > > applies to ASP.NET. I have a library which does some operations on Excel > > > documents, and it will be used in an ASP.NET application. If I use the > > > library in a Forms application, the Excel process is removed when the > > > cleanup operations are done, but with ASP.NET all possible ways to clean > > up > > > fails. > > > > > > The following code has been tried: > > > > > > Application app = new ApplicationClas s(); > > > Workbook wb = null; > > > > > > // some code... no sheet reference done, only doing wb.load, x = > > > wb.Worksheets.C ount, wb.close > > > > > > // release workbook > > > ReleaseComObjec t(wb); > > > wb = null; > > > > > > app.Quit(); > > > ReleaseComObjec t(app); > > > app = null; > > > > > > When the method is called from a windows app, Excel is now gone, but > when > > > called from ASP.NET the Excel process remains. > > > > > > So we gathered that the process had to be killed manually. Off to the > > Win32 > > > api to find some functions. Et voila, we find GetWindowThread ProcessId. > > But > > > what do you know? When the method is called from a windows app, the > > process > > > ID is filled and we can kill the process, but when called from ASP.NET, > > the > > > process ID is 0, the thread ID is 0, and Excel is still lingering > about.. > > > > > > I for one am ready to be committed to the local asylum... > > > > > > Any help greatly appreciated.... .. > > > > > > Lars-Erik > > > > > > > > > >
"Johnny Fugazzi" <re************ *******@ldmkusa .com> wrote in message
news:Oc******** ******@TK2MSFTN GP14.phx.gbl...
<snip> objPtr = New System.IntPtr(x Excel.Hwnd)
The excel application is run from a non-interactive user acount in this
case, so it doesn't interact with the desktop and doesn't have a window.
Your best shot would be to use platform invoke to find and exit the
process - EnumProcesses (psapi.dll), OpenProcess (kernel32.dll),
GetModuleBaseNa me (psapi.dll), ExitProcess (kernel32.dll) and CloseHandle
(kernel32.dll).
Hope this helps
Martin Dechev
ASP.NET MVP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 solve with
this sentence:
System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
|
by: Micke |
last post by:
I want to open Excel from an aspx page, put some records in there, format
them and close the excel file. I can't open the Excel application.
It says Cannot create ActiveX component.
Here is the code:
Imports Excel = Microsoft.Office.Interop.Excel
Public Class MG
Inherits System.Web.UI.Page
|
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 recommended by
many for web applications. I create the instances of Excel, Workbook and the
worksheet. And later on Release the references by
“System.Runtime.InteropServices.Marshal.ReleaseComObject(Object)” and making
the object as null finally....
|
by: Jennyfer Barco |
last post by:
Hello, I have a question, how can I open Microsoft Excel from .NET. I only
need to open a new file in Excel and paste some information and set the
Microsoft Excel as the enabled aplication, so the user can continue working
in Excel and he'll save the information I pasted. I tried this but doesn't
open Excel at all, but it does save the file c:\test.xls with the value
"This is column B row 2" in colum B and row 2:
Dim xlApp As...
|
by: liam_jones |
last post by:
I'm very new to Python, well IronPython to precise, and have been
having problems when using Excel.
The problem I'm having is the closing of my Excel object. I'm able to
successfully quit the Excel Application that I create, but when I open
a Workbook in the Application I can't successfully Quit Excel (by this
I mean I can quit it, but the Excel process isn't getting killed and I
have to manually go this through Task Manager).
I've...
| |
by: KaNos |
last post by:
Hello,
I'm programming an C# application which uses Automation. The problem is
when I quit the application a ghost of excel is always running (Can be
seen in all processes with th task manager). What is the solution ?
Thanks
|
by: sfeinst |
last post by:
I am trying to access Excel spreadsheets to modify data from a VB.NET
application. If I have an object defined as:
Public Class Test
Private _excel As Microsoft.Office.Interop.Excel.Application
Public Property ExcelApp() As
Microsoft.Office.Interop.Excel.Application
Get
Return _excel
End Get
|
by: chuckie_9497 |
last post by:
hello all you gurus. I am struggling with releasing com objects. I
have isolated the problem to the code below. Objects are released and
the process ends until I
use "int k = sheet.Count;" Then the process does not end. So I feel
confident the problem occurrs here. It appears another reference is
created that needs to be closed. Can anyone tell me how to do
this? :)
Thank you
Excel.Workbook workbook =
|
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.
The following code (Test1) demonstrates the essence of what I am doing.
When I check the processes while ruinning the method, I notice that the Excel
process remains after exiting the sub (and until I exit the application)
Sub Test1
Dim...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |