我有一个实用程序类,其中包含一些与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爆炸有一个错误代码,如果我理解正确的话,提供的信息不会比错误意外!
以下是例外:
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
答案 0 :(得分:2)
该程序正在通过任务计划程序执行。失败的实例在最小的priveliges下运行。
我认为一个具有合理描述的SecurityException会更有意义,但是一旦将计划任务配置为更加有效的过程运行,问题就会消失。