473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel interop from ASP.NET - Process can't be killed

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
Nov 18 '05
10 3073
Then do 2 things.

First, research finding processes and how to kill them (you'll be looking
for Excel.exe...its case sensitive)

Secondly, tell the client that the solution will be unstable, as per
Microsoft's warnings unless they choose to invest in a 3rd party product
that can perform this functionality. You need to keep your posterior
covered because when the server locks up, they need to know that it was
their decision that made it happen.
"Johnny Fugazzi" <re************ *******@ldmkusa .com> wrote in message
news:uy******** ********@TK2MSF TNGP12.phx.gbl. ..
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
> > >
> > >
> >
> >



Nov 19 '05 #11

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

Similar topics

5
13334
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);
1
1907
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
2
5438
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....
3
7426
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...
0
2758
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...
3
2214
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
2
2022
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
13
3014
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 =
7
2165
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...
0
9645
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, 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...
0
9481
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,...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9953
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 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...
0
8978
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 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...
1
7502
isladogs
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...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
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...
3
2881
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.