Tag Archives: Remoting

VS 2010 Unit Test Problem with DataSet and Remoting

We ran into problems when using Visual Studio 2010 Unit Tests targeting Framework 3.5.

We use Visual Studio 2010 for our development, but we still use .NET Framework 3.5, because our customers a not ready to run .NET 4.0 applications.

Problem description in detail

When trying to transfer a DataSet instance over .NET Remoting and the executing client is a unit test environment, then it fails with an exception: “AssemblyResolveException…System.Data not found…”

.NET Remoting uses the XmlSerializer to serialize and deserialize DataSets over Remoting boundaries.
The XmlSerializer itself generates a dynamic in-memory assembly for each root-type in the object graph it serializes. This assembly is used to serialize or deserialize the object graph. That means initially the XmlSerializer creates a dynamic assembly with a reference to System.Data, because Visual Studio 2010 executes its Unit Tests with the runtime 4.0.

On server side .NET Remoting is trying to deserialize the DataSet of Version (because of the System.Data reference on client side). The deserialization process fails, because the server is running with Framework version 3.5.
Unfortunately VS2010 does not allow setting another Framework version for unit test projects, only version 4.0 is supported (http://connect.microsoft.com/VisualStudio/feedback/details/483939/unable-to-change-target-framework-version-on-unit-test-projects).

Possible solutions so far

  1. Migrate client and server to .NET 4.0
  2. Run unit tests with VS 2008
  3. Implement the AssemblyResolve event on server side and redirect to the System.Data
  4. Add an assemblyBinding element to the server’s config file to redirect System.Data to System.Data
  5. Waiting for a new Visual Studio Version which supports different target frameworks for unit test projects.

Our solution

We use the assemblyBinding element to redirect the System.Data assembly request to System.Data If we put the following config section into our application server app.config then we are able to use VS2010 for our Unit Tests targeting Framework 3.5.

   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089"/>
          <bindingRedirect oldVersion="" newVersion=""/>



Tagged ,