.NETGURU
Any news on the release Excel bug?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.interop.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Lars-Erik Aabech
I'll just refer to
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=9DEB3050-8CBF-4E69-BC9B-9FD22E8AE536%40microsoft.com&rnum=3&prev=/groups%3Fq%3Dexcel%2520quit%2520interop%2520process%2520asp.net%26num%3D20%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg
and ask if the problem has got a solution yet..

I've got the following code in a class library, and it doesn't release
Excel.exe when called from ASP.NET. Fifty page requests, and the server is
out of memory... That's nice :)

Any help to make it make Excel go away would be very much appreciated. :)

L-E

public int GetSheetCount(string path)
{

Application app = null;
Workbook wb = null;
int iRet = 0;
Exception outerEx = null;
try
{
// Culture hack...
System.Globalization.CultureInfo ciOld =
System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("en-US");
// End cult. hack. 1

app = new ApplicationClass();
app.DisplayAlerts = false;
app.Visible = false;

wb = app.Workbooks.Open(path, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
iRet = wb.Worksheets.Count;
wb.Close(false, Missing.Value, Missing.Value);

// Culture hack
System.Threading.Thread.CurrentThread.CurrentCulture = ciOld;
// End cuilt. hack 2
}
catch(Exception ex)
{
outerEx = ex;
}

Marshal.ReleaseComObject(wb);
wb = null;

app.Quit();
Marshal.ReleaseComObject(app);
app = null;

GC.Collect();
GC.WaitForPendingFinalizers();

// Excel process still active... ReleaseComObject() == 0 for both

if (outerEx != null)
throw(outerEx);

return iRet;

}

Reply to this message...
 
    
Willy Denoyette [MVP] (VIP)
The article you refer to has nothing in common with your problem.
You should know that Office products are not qualified to run in a server
environment and are not supported as MSFT said (see details in Paul's
reply).
One thing you could do is chack wheter you have set aspcompat= true in your
aspx page.
<%@ Page aspcompat="true" ...%>

Anyway, I can guarantee that if you continue to use Office from asp or
asp.net you are in for a lot of troubles.

Willy.

"Lars-Erik Aabech" <Click here to reveal e-mail addressLOCK> wrote in
message news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Paul Clement
On Thu, 9 Sep 2004 13:46:24 +0200, "Lars-Erik Aabech" <Click here to reveal e-mail addressLOCK>
wrote:

¤ I'll just refer to
¤ http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=9DEB3050-8CBF-4E69-BC9B-9FD22E8AE536%40microsoft.com&rnum=3&prev=/groups%3Fq%3Dexcel%2520quit%2520interop%2520process%2520asp.net%26num%3D20%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg
¤ and ask if the problem has got a solution yet..
¤
¤ I've got the following code in a class library, and it doesn't release
¤ Excel.exe when called from ASP.NET. Fifty page requests, and the server is
¤ out of memory... That's nice :)
¤

Unless it's client-side automation I doubt that it would be addressed. Server side automation with
the Microsoft Office applications via unattended or non-interactive client applications has too many
potential problems and as a result Microsoft does not support this type of implementation.

INFO: Considerations for Server-Side Automation of Office
http://support.microsoft.com/default.aspx?scid=kb;en-us;257757

Paul ~~~ Click here to reveal e-mail address
Microsoft MVP (Visual Basic)
Reply to this message...
 
    
Lars-Erik Aabech
Thanks guys. I've gotten the "INFO: Considerations for SS Automation of
Office" link in three forums by now. I can see it's a dead end.
I've rewritten the current code to use ADO instead since it's only going to
fetch information. It will do for now.

Hope there will be some improvements in office 2005 (?) though :)
Lots of users want this functionality...

Lars-Erik

"Lars-Erik Aabech" <Click here to reveal e-mail addressLOCK> wrote in
message news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.GC
System.Globalization.CultureInfo
System.Reflection.Missing
System.Runtime.InteropServices.Marshal
System.Threading.Thread




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification