Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# OpenXml,无法创建互斥体_C#_.net_Excel_Ms Office_Openxml - Fatal编程技术网

C# OpenXml,无法创建互斥体

C# OpenXml,无法创建互斥体,c#,.net,excel,ms-office,openxml,C#,.net,Excel,Ms Office,Openxml,我试图通过openXml库创建Excel文档,但当我想从大量数据创建Excel时,server shoe me无法创建互斥体。(HRESULT异常:0x80131464)错误, 堆栈跟踪是: [IsolatedStorageException: Unable to create mutex. (Exception from HRESULT: 0x80131464)] System.IO.IsolatedStorage.IsolatedStorageFile.Open(String info

我试图通过openXml库创建Excel文档,但当我想从大量数据创建Excel时,server shoe me无法创建互斥体。(HRESULT异常:0x80131464)错误, 堆栈跟踪是:

[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
[IsolatedStorageException:无法创建互斥锁。(来自HRESULT的异常:0x80131464)]
System.IO.IsolatedStorage.IsolatedStorageFile.Open(String infoFile,String syncName)+0
System.IO.IsolatedStorage.IsolatedStorageFile.Lock(布尔值和锁定)+370
System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(字符串路径、文件模式、文件访问访问、文件共享、Int32 bufferSize、IsolatedStorageFile isf)+468
System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(字符串路径、文件模式、文件访问访问、文件共享、IsolatedStorageFile isf)+35
MS.Internal.IO.Packaging.SafeIsolatedStorageFileStream..ctor(字符串路径、文件模式、文件访问访问、文件共享、可靠IsolatedStorageFileFolder文件夹)+102
MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStreamWithRandomName(Int32 retryCount、字符串和文件名)+276
MS.Internal.IO.Packaging.SparseMemoryStream.EnsureIsolatedStream()+31
MS.Internal.IO.Packaging.SparseMemoryStream.switchModeif()+400
MS.Internal.IO.Packaging.compressionStream.Write(字节[]缓冲区,Int32偏移量,Int32计数)+76
MS.Internal.IO.Packaging.CompressStream.Write(字节[]缓冲区,Int32偏移量,Int32计数)+431
MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.Write(字节[]缓冲区,Int32偏移量,Int32计数)+177
MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Write(字节[]缓冲区,Int32偏移量,Int32计数)+130
System.Xml.XmlUtf8RawTextWriter.FlushBuffer()+7519035
System.Xml.XmlUtf8RawTextWriter.RawText(Char*pSrcBegin,Char*pSrcEnd)+232
System.Xml.XmlUtf8RawTextWriter.WriteStarElement(字符串前缀、字符串localName、字符串ns)+192
System.Xml.XmlWellFormedWriter.WriteStarElement(字符串前缀、字符串localName、字符串ns)+7517920
DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter XmlWriter)+283
DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContento(XmlWriter w)+114
DocumentFormat.OpenXml.openxmlement.WriteTo(XmlWriter)+316
DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContento(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(布尔值disposing)+32
DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose()+24
Yara.Evento.Utility.Office.Excel.Write.Do(列出'1个对象,字符串sheetName,HeaderList headerNames)+2371
Yara.Evento.Management.Web.Controllers.TicketController.List(字符串按钮,可空`1页,字符串起始日期,字符串结束日期,字符串所有者邮箱,字符串事件名称,字符串移动,字符串电子邮件,字符串ticketCode,Int32排序,布尔描述,Int32事件ID,Int32状态,Int32 Variatid)+13628
lambda_方法(闭包、控制器库、对象[])+864
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext ControllerContext,IDictionary`2参数)+264
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext ControllerContext,ActionDescriptor ActionDescriptor,IDictionary`2参数)+39
System.Web.Mvc.c__显示类15.b__12()+124
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter筛选器、ActionExecutingContext预文本、Func`1 continuation)+726390
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext ControllerContext,IList`1筛选器,ActionDescriptor ActionDescriptor,IDictionary`2参数)+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__显示类b.b__5()+62
System.Web.Mvc.Async.c__显示类1.b__0()+15
System.Web.Mvc.c_uuudisplayClasse.b_uuud()+52
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+606
System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值&同步完成)+288

我将应用程序池标识更改为在IIS中具有完全控制访问权限的更高级别帐户


IIS>应用程序池>高级设置>标识(在处理模式下)>选择具有更高访问权限的帐户

我同意@Behrooz,将应用程序池的标识更改为本地系统,它将正常工作

当项目在我电脑的本地主机上运行时,我没有遇到这个问题,但当我将其部署到服务器时,我遇到了这个问题

请参见此屏幕截图:


似乎将应用程序池的标识更改为LocalSystem并不总是有帮助,这在我使用Windows Server 2009 R2时就是如此。奇怪的是,自从我读了这个主题并解决了基于OpenXML的大型报告的问题以来,它已经工作了大约半年,但几天前它就停止了工作


因此,经过一天的研究,我发现在ApplicationPool的高级设置中,另外设置将用户配置文件加载到True(默认值为False),并且再次没有问题。

OpenXML对大文件大小使用IsolatedStorage。更多信息请访问

您可以在C:\Users\username\AppData\Local中找到isolatedStorage文件夹。我们发现,当这个文件夹为空时没有出现“无法创建互斥”异常。在重新启动IIS之后,我们也没有立即得到异常。我们发现它有t
<reporting enabled="true"/>