27 February 2006

Diagnosing Binary Formatter Version Incompatability Problems

Clients consuming remoting services hosted in IIS (and therefore exposed via the HTTP channel) configured to use the binary formatter may receive the following error:

An unhandled exception of type 'System.Runtime.Serialization. SerializationException' occurred in mscorlib.dll

Additional information: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 1008738336.1684104552.

This article explains that the above error is masking the original exception, and describes a mechanism for tracing this exception. However, this tracing process requires opening additional ports on the server, which may be problematic if the application under inspection is hosted in a secured environment.

An alternative to tracing the error is to configure the remoting service to use the SOAP formatter instead of the binary formatter, which will allow the original exception to propogate to the client correctly. The SOAP formatter is the default formatter for the HTTP channel, so assuming the remoting system is configured declaratively, the following elements can be removed/commented out of the configuration files:

Client

<configuration>
    <system.runtime.remoting>
        <application>
            <channels>
                <channel ref="http">
                    <clientProviders >
                       
<formatter ref ="binary" />
                   
</clientProviders >
                </channel>
            </channels>
        </application>
    </system.runtime.remoting>
</configuration>


Server

<configuration>
  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="http"port="1234">
          <serverProviders >
           
<formatter ref ="binary" />
         
</serverProviders >
        </channel>
      </channels>
    </application>
  </system.runtime.remoting>
</configuration>


Also note that custom errors must be disabled on the server for the original exception to propogate correctly:

<configuration>
    <system.web>
         <customErrors mode="Off" />
    </system.web>
</configuration>

Filed under:
 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 
(required)
captcha Image