-
July 26th, 2014, 02:46 AM
#1
Office automation throws exception upon initialization
I have a webapp where the user can make excel sheets. It's been working fine for some time, but suddenly things start to fail.
When I initialize my Excel process I get an exception.
Code:
Code:
xlApp = new Excel.Application();
if (xlApp == null)
m_log.WriteLogLine("xlApp is null", LogLevel.High, LogType.Info);
xlApp.DisplayAlerts = false;
xlWorkBook = xlApp.Workbooks.Add(misValue);
I get the exception:
[OutOfMemoryException: Insufficient memory to continue the execution of the program.]
Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template)
I've checked that there's enough ram and hhd space, and that we have access to our file destination (even though we're far from the place where we actually try to write to the disk).
Anyone who knows what may cause this and how to fix it?
Edit: I use Office 2013
Last edited by Lars_V_J; July 26th, 2014 at 02:49 AM.
-
July 28th, 2014, 12:44 PM
#2
Re: Office automation throws exception upon initialization
Talk to the ISP and ask them. Sounds like a setting that can be changed.
-
July 28th, 2014, 02:11 PM
#3
Re: Office automation throws exception upon initialization
It is on an intranet...
I even ran the browser on the server
-
July 28th, 2014, 11:32 PM
#4
Re: Office automation throws exception upon initialization
Check the logs on the server, then.
-
July 29th, 2014, 10:24 AM
#5
Re: Office automation throws exception upon initialization
If you are not cleaning up the objects, you may be holding onto COM references, so clean up after yourself.
Wrap the xlApp call inside a using block.
Code:
using( var xlApp = new Excel.Application())
{
if (xlApp == null)
m_log.WriteLogLine("xlApp is null", LogLevel.High, LogType.Info);
xlApp.DisplayAlerts = false;
xlWorkBook = xlApp.Workbooks.Add(misValue);
}
If Excel.Application doesn't support the IDisposable interface, then explicitly call Close() (or read the documentation on what to call).
Do the same for xlWorkBook.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|