gpt4 book ai didi

.net - XmlSchema.Read 给出 COMException "Catastrophic failure"

转载 作者:行者123 更新时间:2023-12-03 02:05:52 39 4
gpt4 key购买 nike

我有一个实用程序类,其中包含一些与 XML 模式相关的方法。在没有任何代码更改或对环境进行任何已知更改的情况下,它突然开始系统性失败。

失败的方法:

public static XmlSchema GetSchema(string xsdFileName)
{
string path = MyConfiguration.XmlSchemaLocation;
if (!path.EndsWith(@"\"))
{
path += @"\";
}

path += xsdFileName;
return XmlSchema.Read(File.OpenRead(path), null);
}

堆栈跟踪显示 XmlSchema.Read 在内部尝试构造一个 Parser 对象,并且该对象的构造函数尝试读取某些配置,这反过来会导致检查一些策略证据,然后它会因 COMException 而爆炸带有错误代码,如果我理解正确的话,除了意外错误之外,它不会提供更多信息!

异常(exception)情况如下:

System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at System.Security.Policy.PEFileEvidenceFactory.GetLocationEvidence(SafePEFileHandle peFile, SecurityZone& zone, StringHandleOnStack retUrl)
at System.Security.Policy.PEFileEvidenceFactory.GenerateLocationEvidence()
at System.Security.Policy.PEFileEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.AssemblyEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.GetHostEvidence(Type type, Boolean markDelayEvaluatedEvidenceUsed)
at System.Security.Policy.AppDomainEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.RawEvidenceEnumerator.MoveNext()
at System.Security.Policy.Evidence.EvidenceEnumerator.MoveNext()
at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Xml.Schema.Parser..ctor(SchemaType schemaType, XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler)
at System.Xml.Schema.XmlSchema.Read(XmlReader reader, ValidationEventHandler validationEventHandler)
at MyProj.Common.XSDValidator.GetSchema(String xsdFileName)
at ...

知道如何进一步调查这个问题吗?有谁知道什么样的事情可能导致这种情况开始发生(例如,进程正在执行的身份的用户配置文件已损坏)?

这发生在生产环境中,我真的不知道如何继续找出导致它的原因,或修复它。

如果相关:代码托管在控制台应用程序中。请注意,代码在崩溃前不久已成功访问配置。 (“MyConfiguration”类是另一个实用程序类,它基本上是一个薄层,封装了一堆使用普通 System.Configuration.ConfigurationManager 类的 appSettings 键。)

Windows 版本:

OS Name:                   Microsoft® Windows Server® 2008 Datacenter
OS Version: 6.0.6002 Service Pack 2 Build 6002
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Server
OS Build Type: Multiprocessor Free

最佳答案

该程序正在通过任务计划程序执行。失败的实例在最低权限下运行。

我认为带有合理描述的 SecurityException 会更有意义,但是一旦将计划任务配置为作为更特权的进程运行,问题就消失了。

关于.net - XmlSchema.Read 给出 COMException "Catastrophic failure",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23603701/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com