2013-10-19 46 views
3

我試圖通過openXml lib創建Excel文檔,但是當我想從大量數據創建Excel時,服務器鞋我無法創建互斥體。 (異常來自HRESULT:0x80131464)錯誤, 堆棧跟蹤是:OpenXml和無法創建互斥體

[IsolatedStorageException: Unable to create mutex. (Exception from HRESULT: 0x80131464)] 
    System.IO.IsolatedStorage.IsolatedStorageFile.Open(String infoFile, String syncName) +0 
    System.IO.IsolatedStorage.IsolatedStorageFile.Lock(Boolean& locked) +370 
    System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf) +468 
    System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, IsolatedStorageFile isf) +35 
    MS.Internal.IO.Packaging.SafeIsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, ReliableIsolatedStorageFileFolder folder) +102 
    MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStreamWithRandomName(Int32 retryCount, String& fileName) +276 
    MS.Internal.IO.Packaging.SparseMemoryStream.EnsureIsolatedStoreStream() +31 
    MS.Internal.IO.Packaging.SparseMemoryStream.SwitchModeIfNecessary() +400 
    MS.Internal.IO.Packaging.CompressEmulationStream.Write(Byte[] buffer, Int32 offset, Int32 count) +76 
    MS.Internal.IO.Packaging.CompressStream.Write(Byte[] buffer, Int32 offset, Int32 count) +431 
    MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.Write(Byte[] buffer, Int32 offset, Int32 count) +177 
    MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Write(Byte[] buffer, Int32 offset, Int32 count) +130 
    System.Xml.XmlUtf8RawTextWriter.FlushBuffer() +7519035 
    System.Xml.XmlUtf8RawTextWriter.RawText(Char* pSrcBegin, Char* pSrcEnd) +232 
    System.Xml.XmlUtf8RawTextWriter.WriteStartElement(String prefix, String localName, String ns) +192 
    System.Xml.XmlWellFormedWriter.WriteStartElement(String prefix, String localName, String ns) +7517920 
    DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter) +283 
    DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w) +114 
    DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter) +316 
    DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w) +114 
    DocumentFormat.OpenXml.OpenXmlPartRootElement.WriteTo(XmlWriter xmlWriter) +404 
    DocumentFormat.OpenXml.OpenXmlPartRootElement.SaveToPart(OpenXmlPart openXmlPart) +217 
    DocumentFormat.OpenXml.Packaging.OpenXmlPackage.SavePartContents() +203 
    DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose(Boolean disposing) +32 
    DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose() +24 
    Yara.Evento.Utility.Office.Excel.Write.Do(List`1 objects, String sheetName, HeaderList headerNames) +2371 
    Yara.Evento.Management.Web.Controllers.TicketController.List(String button, Nullable`1 page, String startDate, String endDate, String ownerMail, String eventName, String mobile, String eMail, String ticketCode, Int32 sort, Boolean desc, Int32 eventId, Int32 status, Int32 variantId) +13628 
    lambda_method(Closure , ControllerBase , Object[]) +864 
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39 
    System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +124 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +726390 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +309 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +726324 
    System.Web.Mvc.Controller.ExecuteCore() +159 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +334 
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62 
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15 
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +52 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288 
+0

嘗試以'提升的權限(以管理員身份運行)'運行您的應用程序'。看看是否能解決你的問題。 –

回答

2

我更改應用程序池標識上級帳戶在IIS中的完全控制權限。

IIS>應用程序池>高級設置>身份(在過程模式下)>選擇具有較高訪問

+1

但我無法訪問生產服務器IIS設置,那麼我怎麼能解決這個問題 –

+0

我不喜歡接受的答案,因爲它需要運行IIS與提升的權限,這是一個安全弱點,所以我已經下了這個問題。 –

2

我@Behrooz同意的賬戶,改變了ApplicationPool的身份本地系統,它會工作。

我沒有當該項目在我的電腦的本地主機上運行的這個問題,但我沒有當我部署到服務器..

看到這個截圖:

enter image description here

5

似乎將ApplicationPool的Identity更改爲LocalSystem並不總是有助於我的Windows Server 2009 R2。奇怪的是,自從我閱讀了這個主題並解決了我基於OpenXML的大型報告的問題後,它工作了大約半年,但幾天前它剛剛停止工作。

所以研究了一天後,我發現,在另外ApplicationPool的高級設置設置加載用戶配置(默認值是假的),沒有問題又來。

+0

有關何種加載用戶配置文件的詳細信息@ https://blogs.msdn.microsoft.com/vijaysk/2009/03/08/iis-7-tip-3-you-can-now-load-the-user-profile- of-the-application-pool-identity /以及@ http://www.iis.net/learn/manage/configuring-security/application-pool-identities它使用應用程序池的名稱創建用戶配置文件。它包含C:\ Users \ <應用程序池名稱> \ AppData \ Local \ IsolatedStorage \這個路徑我解決了我的問題 –

+0

我不喜歡接受的答案,因爲它需要使用提升的權限運行IIS,這是一個安全弱點。 –

+0

對我來說,我有我的身份設置爲** ApplicationPoolIdentity **,並且一旦我將Load User Profile更改爲** True **一切正常。 –