Reputation: 323
We have encountered an Xslt load problem in our production environment. My colleague tested the production code and reproduced the problem in his pc. However, he could not fix it. So, I have decided to write a sample console application to test in my pc. I did and there was no problem. After that, we have implemented my approach to the production code and tested it on my colleague's pc but it crashed again. After that I sent my sample console application to my colleague and it crashed on his computer again, but I would like to remind that it is working on my computer. Therefore, he installed my version .Net Core from scratch but the sample console application crashed again. The necessary information is below.
Part of sample console application:
... some code to initialize to access object storage
XslCompiledTransform xslTransformer = new XslCompiledTransform();
byte[] data = sm.Get("some-key").GetAwaiter().GetResult(); // gets data from objects storage
var doc = XmlHelper.CreateXmlDocument(data); // create xml document
var nodeList = doc.GetElementsByTagName("cbc:EmbeddedDocumentBinaryObject"); // get xslt in base64 format from xml document
var asBytye = Convert.FromBase64String(nodeList[0].InnerXml); // convert base64 xslt to byte[] xslt
// byte length and initial data are the same we have checked
//load xslt to transformer
using (var reader = new MemoryStream(asBytye))
using (var sr = new StreamReader(reader, Encoding.UTF8)) // we have tried other encodings
using (XmlReader xr = XmlReader.Create(sr))
{
xslTransformer.Load(xr); // here my machine gets no exception, however, the other machine get the error below
}
.. some code
Here is CreateXmlDocument
function:
public static XmlDocument CreateXmlDocument(byte[] dataAsByte)
{
XmlDocument document = new XmlDocument
{
PreserveWhitespace = true
};
using (MemoryStream memoryStream = new MemoryStream(dataAsByte, false))
{
document.Load(memoryStream);
}
return document;
}
Here is the stack trace:
Exception has occurred: CLR/System.Xml.Xsl.XslTransformException
An unhandled exception of type 'System.Xml.Xsl.XslTransformException' occurred in System.Private.Xml.dll: 'Unsupported option 'descendingOrder' in collation.'
at System.Xml.Xsl.Runtime.XmlCollation.Create(String collationLiteral, Boolean throwOnError)
at System.Xml.Xsl.IlGen.StaticDataManager.DeclareCollation(String collation)
at System.Xml.Xsl.IlGen.XmlILVisitor.VisitSortKey(QilSortKey ndKey, LocalBuilder locKeys)
at System.Xml.Xsl.IlGen.XmlILVisitor.VisitSort(QilLoop ndSort)
at System.Xml.Xsl.Qil.QilVisitor.Visit(QilNode n)
at System.Xml.Xsl.IlGen.XmlILVisitor.Visit(QilNode nd)
at System.Xml.Xsl.IlGen.XmlILVisitor.StartForBinding(QilIterator ndFor, OptimizerPatterns patt)
at System.Xml.Xsl.IlGen.XmlILVisitor.StartBinding(QilIterator ndIter)
at System.Xml.Xsl.IlGen.XmlILVisitor.VisitLoop(QilLoop ndLoop)
at System.Xml.Xsl.Qil.QilVisitor.Visit(QilNode n)
at System.Xml.Xsl.IlGen.XmlILVisitor.Visit(QilNode nd)
at System.Xml.Xsl.IlGen.XmlILVisitor.NestedVisit(QilNode nd, Type itemStorageType, Boolean isCached)
at System.Xml.Xsl.IlGen.XmlILVisitor.NestedVisit(QilNode nd)
at System.Xml.Xsl.IlGen.XmlILVisitor.VisitConditional(QilTernary ndCond)
at System.Xml.Xsl.Qil.QilVisitor.Visit(QilNode n)
at System.Xml.Xsl.IlGen.XmlILVisitor.Visit(QilNode nd)
at System.Xml.Xsl.IlGen.XmlILVisitor.NestedVisit(QilNode nd, Type itemStorageType, Boolean isCached)
at System.Xml.Xsl.IlGen.XmlILVisitor.VisitSequence(QilList ndSeq)
at System.Xml.Xsl.Qil.QilVisitor.Visit(QilNode n)
at System.Xml.Xsl.IlGen.XmlILVisitor.Visit(QilNode nd)
at System.Xml.Xsl.IlGen.XmlILVisitor.NestedVisit(QilNode nd, Type itemStorageType, Boolean isCached)
at System.Xml.Xsl.IlGen.XmlILVisitor.NestedVisit(QilNode nd)
at System.Xml.Xsl.IlGen.XmlILVisitor.Function(QilFunction ndFunc)
at System.Xml.Xsl.IlGen.XmlILVisitor.Visit(QilExpression qil, GenerateHelper helper, MethodInfo methRoot)
at System.Xml.Xsl.XmlILGenerator.Generate(QilExpression query, TypeBuilder typeBldr)
at System.Xml.Xsl.XslCompiledTransform.CompileQilToMsil(XsltSettings settings)
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet)
at Test.Program.Main(String[] args)
Here is the dotnet --info
output:
.NET Core SDK (reflecting any global.json):
Version: 2.1.403
Commit: 04e15494b6
Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299 // only this is different between two computers
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.403\
Host (useful for support):
Version: 2.1.5
Commit: 290303f510
.NET Core SDKs installed:
2.1.403 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Upvotes: 1
Views: 218