Microsoft Knowledge Base Email Alertz

Error message when you try to use a client application that is built on the .NET Framework 1.1 to consume a .NET Framework 2.0-based Web service: System.InvalidOperationException

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 929545 - Last Review: December 21, 2006 - Revision: 1.2

Error message when you try to use a client application that is built on the .NET Framework 1.1 to consume a .NET Framework 2.0-based Web service: "System.InvalidOperationException"

SYMPTOMS

When you try to use a Microsoft .NET Framework 1.1-based client to consume a Microsoft .NET Framework 2.0-based Web service, you may receive an error message that resembles the following:
System.InvalidOperationException: There is an error in XML document (1, 446). --->
System.FormatException: Input string was not in a correct format. at System.Number.ParseUInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Xml.XmlConvert.ToUInt32(String s)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderTestWs.Read1_Object1(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderTestWs.Read6_GetMethodResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly. GetMethodResponseSerializer.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
This behavior may also occur when you use a Java-based client.

Note This behavior does not occur when you use a .NET Framework 2.0-based client.

CAUSE

This behavior occurs because the .NET Framework 1.1 does not support deserialization of nullable value types.

WORKAROUND

To work around this behavior, modify the proxy class for the client application to convert nullable value types to reference types. In the following example, the nullable int type is converted to the string type. When the string value is returned, the value is converted back to the int type.

For example, the code for the proxy class for the client application may resemble the following code example.
public class MyClass
{
  public int id;
}
To work around this problem, replace the code for the proxy class with the following code example.
public class MyClass
{
  [XmlElement(IsNullable = true)]
  public string id;

  [XmlIgnore]
  public int idValue
  {
    get
    {
      if (this.id == null || this.id.Length == 0)
        return 0;
      return Convert.ToInt32(id);
    }
    set
    {
      id = Convert.ToString(value);
    }
  }
}

APPLIES TO
  • Microsoft .NET Framework 1.1
  • Microsoft Web Services Enhancements for Microsoft .NET 1.1
Keywords: 
kbcode kbexcepthandling kbwebclasses kb80004005 kbwebservices kbexpertiseinter kbtshoot kbprb KB929545
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate