XmlSchema.Read使COMException发生“灾难性故障”。 [英] XmlSchema.Read gives COMException "Catastrophic failure"

查看:90
本文介绍了XmlSchema.Read使COMException发生“灾难性故障”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've got a utility class with a few method relating to XML schemas. Without any code changes nor any know changes to the environment, it has suddenly started to fail systematically.

失败的方法:

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炸毁,如果我正确理解的话,该错误代码所提供的信息不超过错误

The stack trace shows XmlSchema.Read is internally attempting to construct a Parser object, and the constructor of this attempts to read some configuration, and this in turn leads to some policy evidence being examined, and then it blows up with a COMException with an error code which, if I understand this correctly, provides no more information than the error being unexpected!

这里是个例外:

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 ...

有人知道如何进一步调查吗?有谁知道是什么原因导致这种情况开始发生(例如,在执行过程的身份下,用户个人资料已损坏)?

Any idea how to investigate this further? Does anyone know what kind of thing may have caused this to start happening (e.g. a corrupt user profile for the identity under which the process is executing)?

生产环境,我真的不知道如何继续找出造成它的原因或解决它。

This has happened in a production envioronment and I really have no idea how to proceed to figure out what has caused it, or to fix it.

如果相关:代码托管在控制台应用程序中。请注意,该代码在爆炸前不久已成功访问了配置。 ( MyConfiguration类是另一个实用程序类,基本上是一个薄层,封装了使用常规System.Configuration.ConfigurationManager类的一堆appSettings密钥。)

In case it's relevant: The code is hosted in a console application. Note that the code has successfully accessed configuration shortly before it blows up. (The "MyConfiguration" class is another utility class that is basically a thin layer encapsulating a bunch of appSettings keys that uses the ordinary System.Configuration.ConfigurationManager class.)

Windows版本:

Windows version:

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


推荐答案

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

The program was being executed via Task Scheduler. The instances that failed were running under minimum priveliges.

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

I reckon a SecurityException with a sensible description would have made more sense, but once the scheduled task was configured to run as a more priveliged process, the problem disappeared.

这篇关于XmlSchema.Read使COMException发生“灾难性故障”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆