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 220.127.116.11 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 18.104.22.168, 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 22.214.171.124 (because of the System.Data 126.96.36.199 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
- Migrate client and server to .NET 4.0
- Run unit tests with VS 2008
- Implement the AssemblyResolve event on server side and redirect to the System.Data 188.8.131.52
- Add an assemblyBinding element to the server’s config file to redirect System.Data 184.108.40.206 to System.Data 220.127.116.11
- Waiting for a new Visual Studio Version which supports different target frameworks for unit test projects.
We use the assemblyBinding element to redirect the System.Data 18.104.22.168 assembly request to System.Data 22.214.171.124. 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.
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089"/> <bindingRedirect oldVersion="126.96.36.199" newVersion="188.8.131.52"/> </dependentAssembly> </assemblyBinding> </runtime>