2013-10-19 44 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 **一切正常。 –