I have a service that uses .NET 3.5 and exposes some methods via .NET remoting. Some of those methods expect a DataSet as an argument. When the client is also running .NET 3.5 everything is fine. However, when the client is running .NET 4 I get the following remote exception (on the server):
Could not load file or assembly ‘System.Data, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089’ or one of its dependencies. The system cannot find the file
specified.
So apparently there are two version of DataSets – version 2 and version 4. I have tried creating a separate .NET 3.5 project where the DataSet is created and sent to the server. But when it is loaded in the .NET 4 runtime along with other .NET 4 assemblies, it still uses DataSet version 4.
The weirdest thing is with a different service also running in .net 3.5 I can send version 4 DataSets with no problems. I have not been able to figure out what is different there.
Any insight or solutions would be greatly appreciated.
Update:
Microsoft seems to be aware of the problem: See here. Pretty sad though if such a hack is really required to communicate between different .NET versions…
The below code implements a custom BinaryFormatterSink that can be used on the client instead of the BinaryClientFormatterSink. It is based on the microsoft example at MSDN