var txnSerializer = new TxnSerializer(); //generated serializer
TextWriter writer = new StringWriter();
txnSerializer.Serialize(writer, response.ReturnValue);
抛出以下异常:
System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=There was an error generating the XML document.
Source=System.Xml
StackTrace:
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o)
at Tests.MiscTests.MyTest() in c:\dev\MiscTests.cs:line 377
InnerException: System.MissingMethodException
HResult=-2146233069
Message=Method not found: 'Project.ClosingInstructionsType Project.Txn.get_ClosingInstructions()'.
Source=Project.Schema.XmlSerializers
StackTrace:
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1761_Txn(String n, String ns, Txn o, Boolean isNullable, Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write3518_Txn(Object o)
at Microsoft.Xml.Serialization.GeneratedAssembly.TxnSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
InnerException:
这里有一个奇怪的部分:除了我的以外,它在团队中的所有其他开发工作站上都能正常工作。这是许多失败测试中的一个,所有失败都有相同的错误。救命啊!
答案 0 :(得分:1)
System.MissingMethodException
几乎总是不正确的.NET应用程序环境的症状(例如,DLL版本不匹配)。我会尝试以下行动:
gacutil /u DLL_NAME
从GAC中删除所有相关程序集。在此之后重新启动IIS。使用gacutil /if "<path to the assembly .dll file>"