ObjectDisposedExceptions and IsolatedStorageException
Home › Forums › Open-Xml-Sdk › ObjectDisposedExceptions and IsolatedStorageException
This topic contains 2 replies, has 2 voices, and was last updated by cygnus18 4 years, 3 months ago.
-
AuthorPosts
-
August 19, 2020 at 7:31 pm #8847
We’re receiving the following exceptions constantly in Production, but not in our Dev and Test environments. running locally using development server also does not cause these exceptions.
ASP.NET MVC ApplicationObjectDisposedException – Can not access a closed Stream.
at System.IO.Compression.DeflateStream.EnsureNotDisposed() at
MS.Internal.IO.Packaging.CompressStream.Flush() at
IsolatedStorageException – Unable to create mutex. (Exception from HRESULT: 0x8013146
there are a lot of references to MS.Internal.IO.Packaging in our stack traceWe’ve set LoadUserProfile = True in our application pool advanced settings and see the IsolatedStorage folders under our application pool.
It’s my understanding that there is a known bug in .NET System.IO.Packaging because it uses IsolatedStorage (which is not thread safe nor can support more than one process using it) when memory usage goes above 10mb. There seems to be a fix for this going back to OpenXML SDK version 2.6. We were using an old version of OpenXML (2.5). This fix uses an implementation of IO.Packaging that does not use IsolatedStorage
Post about the fix in 2015
Announcing the Release of a New System.IO.Packaging Implementation
I’ve installed the latest SDK (DocumentFormat.OpenXml 2.11.3) which has a dependency on System.IO.Packaging” version=”4.7.0″, and it was installed as well. I have references in my project to both of these assemblies.
Has anyone faced this problem or have any suggestions about what I could be missing here?
August 19, 2020 at 8:07 pm #8848I have never heard that this has been fixed in .NET, although my information may be out of date.
If you have multithreaded access, you have only two options:
– Use .NET core, which has a new implementation of System.IO.Packaging.
– Put all Open XML processing out into a separate process (not thread), then use inter process communication.This includes if you are running on a web server that essentially uses multithreading.
Eric
August 20, 2020 at 8:50 pm #8851Thanks for the response Eric. I know this isn’t the place for an in depth discussion of ASP.NET multithreading in IIS. However, since we have very few people in our environment and at times I’m the only person testing I have to assume that potentially multiple threads/worker processes are handling a single request to the server. We currently have 3 load balanced servers in our environment and dev and test each have 2 load balanced servers. I’m not seeing this issue in dev or test. Am I just getting lucky here, and this problem could surface at any moment in our dev and test applications?
-
AuthorPosts
You must be logged in to reply to this topic.