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

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: David Jessee (djessee_at_houston.rr.com)
Date: 01/16/05


Date: Sun, 16 Jan 2005 08:11:17 -0600

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" <removethis-abillmeier@ldmkusa.com> wrote in message
news:uyDfssk%23EHA.1264@TK2MSFTNGP12.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" <djessee@houston.rr.com> wrote in message
> news:%23eKAMuf%23EHA.2596@tk2msftngp13.phx.gbl...
> > 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" <abillmeier@ldmkusa.com> wrote in message
> > news:1105651583.631011.245870@f14g2000cwb.googlegroups.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" <nospam_brubar@safeco.com> wrote in message
> >> > news:Os$0n60lEHA.3988@tk2msftngp13.phx.gbl...
> >> > > microsoft does not recommend this approach:
> >> > >
> >> > > http://support.microsoft.com/default.aspx?scid=kb;EN-US;257757
> >> > >
> >> > > here is the workaround to do the exit
> >> > >
> >> > > http://support.microsoft.com/default.aspx?scid=kb;EN-US;317109
> >> > >
> >> > >
> >> > >
> >> > > -- bruce (sqlwork.com)
> >> > >
> >> > >
> >> > > "Lars-Erik Aabech" <lars-erik.aabech@markedspartner.noSPAMBLOCK>
> >> wrote in
> >> > > message news:OQxZjMxlEHA.1008@tk2msftngp13.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 ApplicationClass();
> >> > > > Workbook wb = null;
> >> > > >
> >> > > > // some code... no *** reference done, only doing wb.load, x =
> >> > > > wb.Worksheets.Count, wb.close
> >> > > >
> >> > > > // release workbook
> >> > > > ReleaseComObject(wb);
> >> > > > wb = null;
> >> > > >
> >> > > > app.Quit();
> >> > > > ReleaseComObject(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
> >> GetWindowThreadProcessId.
> >> > > 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
> >> > > >
> >> > > >
> >> > >
> >> > >
> >>
> >
> >
>
>


Quantcast