我正在我的应用程序上通过Visual Studio团队Server 2005运行自动化测试。该应用程序是一个WCF服务,其BO层具有多线程功能。 VSTS上的用户负载为2,思考时间为20秒(发送一个请求后的等待时间)。但是应用程序通过执行此操作会出现“ System.Threading.ThreadAbortException ”错误。发生错误的特定区域是 XslCompiledTransform transform.Transform(xmlReader,outputXmlWriter)。通过这样做,我实际上尝试将xml(序列化viewmodel后生成xml)提供给xslt对象(Transform)。正常加载应用程序时不会出现“ System.Threading.ThreadAbortException ”错误,而是在多个用户同时访问上述方法时发生错误。详细错误发布在下面;
02/14/2014 01:44:20
类型:System.Threading.ThreadAbortException,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089
消息:线程正在中止。
来源:System.Xml.Xsl.CompiledQuery.1
帮助链接:
异常状态:
数据:System.Collections.ListDictionaryInternal
TargetSite:Void(System.Xml.Xsl.Runtime.XmlQueryRuntime,System.Xml.XPath.XPathNavigator)
Stack Trace:at(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug} runtime,XPathNavigator {urn:schemas-microsoft-com:xslt-debug} current)
在Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}运行时)
at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug} runtime)
在System.Xml.Xsl.XmlILCommand.Execute(对象defaultDocument,XmlResolver dataSources,XsltArgumentList argumentList,XmlSequenceWriter结果)
在System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,XmlResolver dataSources,XsltArgumentList argumentList,XmlWriter writer,Boolean closeWriter)
在System.Xml.Xsl.XmlILCommand.Execute(XmlReader contextDocument,XmlResolver dataSources,XsltArgumentList argumentList,XmlWriter结果)
在System.Xml.Xsl.XslCompiledTransform.Transform(XmlReader输入,XmlWriter结果)
在Proposal.Generator.Presenter.BaseClasses.BaseSectionPresenter 1.GetTransformedXml(String inputFileName, Object viewModelPart)
at Proposal.Generator.Presenter.BaseClasses.BaseSectionPresenter
1. TransformTemplateUsingXslt (String inputXsltName,Stream outpuStream,Object viewModelPart,Boolean addNumberPart,Boolean addstylePart,List 1 richTextPlaceholder, List
1 richText, String wordDoc)
答案 0 :(得分:0)
你说"在多个用户同时访问上述方法时出现#34;。
虽然我发现您的错误来自XslCompiledTransform.Transform()
,而MSDN声明The XslCompiledTransform object is thread safe once it has been loaded. In other words, after the Load method has successfully completed, the Transform method can be called simultaneously from multiple threads.
,但它也会指出Note: The Load method is not thread safe when called simultaneously from multiple threads.
。您的代码是否可能只是这样做(即加载并发),并导致后来的线程错误?