XML Serializer throwing exception: "method not found"

803 views Asked by At
var txnSerializer = new TxnSerializer(); //generated serializer
TextWriter writer = new StringWriter();
txnSerializer.Serialize(writer, response.ReturnValue);

is throwing the following exception:

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: 

Here's the weird part: it works fine on all the other development workstations on the team except mine. This is one of many failing tests, all failing with the same error. Help!

1

There are 1 answers

0
Special Sauce On BEST ANSWER

The System.MissingMethodException is almost always a symptom of an incorrect .NET application environment (eg, DLL version mismatches). I would try the following actions:

  • Rebuild and redeploy the entire solution. Depending on your deployment options, you may want to delete (clean) all existing .DLLs in the deployment folder prior to the redeploy. This exception can happen when old assemblies are lingering around where they shouldn't be. Restart IIS after redeployment.
  • Remove any dependent assemblies from the GAC using gacutil /u DLL_NAME. Restart IIS after this. Reinstall the correct assemblies needed in the GAC with gacutil /if "<path to the assembly .dll file>"