【发布时间】:2016-05-01 18:18:59
【问题描述】:
当我尝试加载 XSLT 时出现以下错误Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
string xmlFilePath = Path.Combine(GetAssemblyDirectory(), "TestResult.xml");
string xslFilePath = Path.Combine(GetAssemblyDirectory(), "SingleTableTestResult.xslt");
strResultSummary = strResultSummary.Replace(ProjectPath, ProjectName);
File.WriteAllText(xmlFilePath, strResultSummary, System.Text.Encoding.UTF8);
//get the formatted HTML Report tranformed via xslt
string reportFileData = GenerateTestReport(xmlFilePath, xslFilePath);
//gets the path of the running assembly directory
private static string GetAssemblyDirectory()
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
DashboardBaseLogger.dashBoardlogger.WriteInfo("Directory location: " + Path.GetDirectoryName(path));
return Path.GetDirectoryName(path);
}
//Generates the test report
private string GenerateTestReport(string XMLFilePath, string XSLFilePath)
{
string reportFilePath = string.Empty;
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(XSLFilePath); //Exception here
reportFilePath = Path.Combine(GetAssemblyDirectory(), "TestResult.html");
transform.Transform(XMLFilePath, reportFilePath);
return reportFilePath;
}
在此处获取异常transform.Load(XSLFilePath); //Getting an Exception here
谁能帮我解决这个问题? 任何帮助将不胜感激。 提前致谢。
【问题讨论】:
-
您写的错误似乎是正常的调试消息,而不是运行时异常。您可以插入一个 try..catch 并编写完整的异常吗?
-
在 Catch 块中,我收到“System.Threading.ThreadAbort”异常。
-
有内部异常?
-
所有异常属性如“Data, Source, Stacktrace, InnerException”都显示了调试信息