G
Guest
Deserializing SqlExceptions on Windows XP (SP2) originating from a Windows
Server 2003 SP1 machine is problemetic. It may generate the following
exception:
Exception: System.Runtime.Serialization.SerializationException
Message: Member name 'System.Data.SqlClient.SqlError server' not found.
Source: System.Runtime.Serialization.Formatters.Soap
at
System.Runtime.Serialization.Formatters.Soap.ReadObjectInfo.Position(String
name)
at
System.Runtime.Serialization.Formatters.Soap.ReadObjectInfo.GetType(String
name)
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseMember(ParseRecord pr)
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Parse(ParseRecord
pr)
at
System.Runtime.Serialization.Formatters.Soap.SoapHandler.EndElement(String
prefix, String name, String urn)
at System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXml()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.Run()
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)
at
System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler)
at
System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream
serializationStream)
I have found out that this is due to an incompatibility between the
System.Data assemblies on both machines. The following assemblies are
installed on both machines:
* Client: Windows XP SP2, System.Data.dll (v1.1.4322.2032)
* Server: Windows Server 2003 SP1, System.Data.dll (v1.1.4322.2300)
A SqlException that is thrown on the Windows Server 2003 SP1 machine
contains an error collection of type SqlError. Such an error will be
serialized like this:
<a3:SqlError id="ref-18"
xmlns:a3="http://schemas.microsoft.com/clr/ns...ture=neutral, PublicKeyToken=b77a5c561934e089">
<source href="#ref-15"/>
<number>50000</number>
<state>1</state>
<errorClass>16</errorClass>
<server id="ref-19">PC1882</server>
<message id="ref-20">-Message here-</message>
<procedure id="ref-21">-Procedure here-</procedure>
<lineNumber>24</lineNumber>
</a3:SqlError>
If the same exception is thrown on a Windows XP SP2 machine, then the
<server> tag is missing. This may seem strange, because the Server property
does exist in the v1.1.4322.2032 version. I started Lutz Roeder's .NET
reflector and it shows that the Server property is some kind of stub that
always returns an empty string. There isn't a server field in the class and
it cannot be set by the class' constructor. This explains why it is not in
the serialized message.
If you load the Windows Server 2003 SP1 assembly into the .NET Reflector,
then there is a server field and the server can be set in the constructor.
When the SqlError is constructed, then the server is saved into the field and
returned when the Server property is requested. This explains why it is in
the serialized message. It is good to have the server property in there, but
it is annoying that it isn't compatible anymore.
The Windows Server 2003 SP1 machine serializes the SqlError and includes the
server tag. The client deserializes the message and encounters the server tag
and doesn't know what to do with it and generates the exception listed above.
Although I can explain what is happening, I cannot solve it (yet). I am
currently working on a solution for this problem, but for now I can only
explain what is happening. For anyone else out there that is facing the same
problem it might be nice to know what is actually happening.
It worries me, that although the version numbers are the same (only a
difference in buildnumber) causes these kind of problems. I thought the
versioning issues would have been resolved with .NET. I hope someone can
bring up a solution. I really don't like to implement my own
SerializationBinder to solve this issue (that is what I am thinking of right
now). Can someone please respond to this issue?
Server 2003 SP1 machine is problemetic. It may generate the following
exception:
Exception: System.Runtime.Serialization.SerializationException
Message: Member name 'System.Data.SqlClient.SqlError server' not found.
Source: System.Runtime.Serialization.Formatters.Soap
at
System.Runtime.Serialization.Formatters.Soap.ReadObjectInfo.Position(String
name)
at
System.Runtime.Serialization.Formatters.Soap.ReadObjectInfo.GetType(String
name)
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseMember(ParseRecord pr)
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Parse(ParseRecord
pr)
at
System.Runtime.Serialization.Formatters.Soap.SoapHandler.EndElement(String
prefix, String name, String urn)
at System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXml()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.Run()
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)
at
System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler)
at
System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream
serializationStream)
I have found out that this is due to an incompatibility between the
System.Data assemblies on both machines. The following assemblies are
installed on both machines:
* Client: Windows XP SP2, System.Data.dll (v1.1.4322.2032)
* Server: Windows Server 2003 SP1, System.Data.dll (v1.1.4322.2300)
A SqlException that is thrown on the Windows Server 2003 SP1 machine
contains an error collection of type SqlError. Such an error will be
serialized like this:
<a3:SqlError id="ref-18"
xmlns:a3="http://schemas.microsoft.com/clr/ns...ture=neutral, PublicKeyToken=b77a5c561934e089">
<source href="#ref-15"/>
<number>50000</number>
<state>1</state>
<errorClass>16</errorClass>
<server id="ref-19">PC1882</server>
<message id="ref-20">-Message here-</message>
<procedure id="ref-21">-Procedure here-</procedure>
<lineNumber>24</lineNumber>
</a3:SqlError>
If the same exception is thrown on a Windows XP SP2 machine, then the
<server> tag is missing. This may seem strange, because the Server property
does exist in the v1.1.4322.2032 version. I started Lutz Roeder's .NET
reflector and it shows that the Server property is some kind of stub that
always returns an empty string. There isn't a server field in the class and
it cannot be set by the class' constructor. This explains why it is not in
the serialized message.
If you load the Windows Server 2003 SP1 assembly into the .NET Reflector,
then there is a server field and the server can be set in the constructor.
When the SqlError is constructed, then the server is saved into the field and
returned when the Server property is requested. This explains why it is in
the serialized message. It is good to have the server property in there, but
it is annoying that it isn't compatible anymore.
The Windows Server 2003 SP1 machine serializes the SqlError and includes the
server tag. The client deserializes the message and encounters the server tag
and doesn't know what to do with it and generates the exception listed above.
Although I can explain what is happening, I cannot solve it (yet). I am
currently working on a solution for this problem, but for now I can only
explain what is happening. For anyone else out there that is facing the same
problem it might be nice to know what is actually happening.
It worries me, that although the version numbers are the same (only a
difference in buildnumber) causes these kind of problems. I thought the
versioning issues would have been resolved with .NET. I hope someone can
bring up a solution. I really don't like to implement my own
SerializationBinder to solve this issue (that is what I am thinking of right
now). Can someone please respond to this issue?