I have a code which I'm doing XslCompiledTransform
as below:
var xslTransform = new XslCompiledTransform();
xslTransform.Load("File.xslt");
Throws Error (When Windows Server Upgraded to 2016 or 2019 version):
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.XmlConfiguration.XsltConfigSection.get_s_ProhibitDefaultUrlResolver()
at System.Xml.XmlConfiguration.XsltConfigSection.CreateDefaultResolver()
at System.Xml.Xsl.XslCompiledTransform.Load(String stylesheetUri)
This above error occurs only in Windows Server 2016 or 2019
versions. It works well in Windows Server 2012 version
What I tried so far:
I tried finding the problem related to Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
and found the link and I tried changing the registry also. But, it is not working as expected.
Tried changing the code as well:
// Create a resolver and specify the necessary credentials.
XmlUrlResolver resolver = new XmlUrlResolver();
System.Net.NetworkCredential myCred;
myCred = new System.Net.NetworkCredential(UserName,SecurelyStoredPassword,Domain);
resolver.Credentials = myCred;
// Load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(new XPathDocument("File.xslt"), XsltSettings.Default, resolver);
I'm in a situation to upgrade the OS to Windows Server 2016 or 2019 and it is breaking like anything.
I'm completely stuck here to get it resolved. Either any solution regarding the code change or regarding windows registry is also fine. I'm stuck for 2 days in this.
Project Details:
Project .NET Framework version - 4.0
Running successfully on Windows Server 2012
Application runs on TaskScheduler
with Highest Privileages
.NET Version Details (Based on Operating System)
Thanks in advance.
AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);
before using XslCompiledTransform and resolvers, does that improve things? – Dow