Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:43:39+00:00 2026-06-14T09:43:39+00:00

I have a service that uses .NET 3.5 and exposes some methods via .NET

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:43:40+00:00Added an answer on June 14, 2026 at 9:43 am

    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

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Reflection;
    using System.Runtime.Remoting.Channels;
    using System.Runtime.Remoting.Messaging;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Formatters;
    using System.Runtime.Serialization.Formatters.Binary;
    using System.Text;
    
    namespace bla
    {
        class VersionConversionClientSinkProvider : IClientChannelSinkProvider
        {
            public IClientChannelSink CreateSink(IChannelSender channel, string url, object remoteChannelData)
            {
                if (Next != null )
                {
                    var nextSink = Next.CreateSink(channel, url, remoteChannelData);
                    if (nextSink != null)
                    {
                        return new VersionConversionClientSink(nextSink);  
                    }
                }
                return null;
            }
    
            public IClientChannelSinkProvider Next { get; set; }
        }
    
        class VersionConversionClientSink : IClientChannelSink, IMessageSink
        {
            public VersionConversionClientSink(IClientChannelSink channel)
            {
                _next = channel;
            }
    
            readonly IClientChannelSink _next;
    
            public IDictionary Properties
            {
                get { return NextChannelSink.Properties; }
            }
    
            public void ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, out ITransportHeaders responseHeaders, out Stream responseStream)
            {
                throw new NotSupportedException();
            }
    
            private void SerializeMessage(IMessage msg, out ITransportHeaders headers, out Stream stream)
            {
                var binaryFormatter = new BinaryFormatter
                    {
                        Binder = new VersionConversionSerializationBinder()
                    };
    
                stream = new MemoryStream();
                binaryFormatter.Serialize(stream, msg);
                stream.Position = 0;
    
                headers = new TransportHeaders();
            }
    
            private IMessage DeserializeMessage(Stream stream)
            {
                var binaryFormatter = new BinaryFormatter
                    {
                        AssemblyFormat = FormatterAssemblyStyle.Simple
                    };
    
                var msg = (IMessage) binaryFormatter.Deserialize(stream);
                stream.Close();
                return msg;
            }
    
            public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
            {
                throw new NotSupportedException();
            }
    
            public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
            {
                sinkStack.AsyncProcessResponse(headers, stream);
            }
    
            public Stream GetRequestStream(IMessage msg, ITransportHeaders headers)
            {
                return _next.GetRequestStream(msg, headers);
            }
    
            public IClientChannelSink NextChannelSink
            {
                get { return _next; }
            }
    
            public IMessage SyncProcessMessage(IMessage msg)
            {
                IMethodCallMessage mcm = msg as IMethodCallMessage;
                try
                {
                    ITransportHeaders headers;
                    Stream stream;
                    SerializeMessage(msg, out headers, out stream);
                    ITransportHeaders responseHeaders;
                    Stream responseStream;
                    NextChannelSink.ProcessMessage(msg, headers, stream, out responseHeaders, out responseStream);
                    if (responseHeaders == null)
                        throw new ArgumentNullException("returnHeaders");
                    else
                        return DeserializeMessage(responseStream);
                }
                catch (Exception ex)
                {
                    return new ReturnMessage(ex, mcm);
                }
            }
    
            public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
            {
                var mcm = (IMethodCallMessage)msg;
                try
                {
                    ITransportHeaders headers;
                    Stream stream;
                    SerializeMessage(msg, out headers, out stream);
                    var channelSinkStack = new ClientChannelSinkStack(replySink);
                    channelSinkStack.Push(this, msg);
                    NextChannelSink.AsyncProcessRequest(channelSinkStack, msg, headers, stream);
                }
                catch (Exception ex)
                {
                    IMessage msg1 = new ReturnMessage(ex, mcm);
                    if (replySink != null)
                        replySink.SyncProcessMessage(msg1);
                }
                return null;
            }
    
            public IMessageSink NextSink
            {
                get { throw new NotSupportedException(); }
            }
        }
    
        class VersionConversionSerializationBinder : SerializationBinder
        {
            string[] frameworkPublicKeyTokens = new string[] {
                    "B7-7A-5C-56-19-34-E0-89",
                    "B0-3F-5F-7F-11-D5-0A-3A",
                    "31-BF-38-56-AD-36-4E-35",
                    "89-84-5D-CD-80-80-CC-91"
                };
    
            bool IsFrameworkAssembly(Assembly assembly)
            {
                foreach (string frameworkToken in frameworkPublicKeyTokens)
                {
                    if (frameworkToken == BitConverter.ToString(assembly.GetName().GetPublicKeyToken()))
                    {
                        return true;
                    }
                }
                return false;
            }
    
            public override void BindToName(Type serializedType, out string assemblyName, out string typeName)
            {
                // To handle arrays
                if (serializedType.IsArray)
                {
                    string elementTypeName;
                    Type elementType = serializedType.GetElementType();
                    BindToName(elementType, out assemblyName, out elementTypeName);
                    StringBuilder typeNameBuilder = new StringBuilder(elementTypeName);
                    typeNameBuilder.Append("[");
                    int arrayRank = serializedType.GetArrayRank();
                    for (int i = 1; i < arrayRank; i++)
                    {
                        typeNameBuilder.Append(",");
                    }
                    if (arrayRank == 1 && serializedType == elementType.MakeArrayType(1))
                    {
                        typeNameBuilder.Append("*");
                    }
                    typeNameBuilder.Append("]");
                    typeName = typeNameBuilder.ToString();
                }
                // To handle generic types
                else if (serializedType.IsGenericType && !serializedType.IsGenericTypeDefinition)
                {
                    string definitionTypeName;
                    Type[] genericParameters = serializedType.GetGenericArguments();
                    BindToName(serializedType.GetGenericTypeDefinition(), out assemblyName, out definitionTypeName);
                    StringBuilder typeNameBuilder = new StringBuilder(definitionTypeName);
                    typeNameBuilder.Append("[");
                    for (int i = 0; i < genericParameters.Length; i++)
                    {
                        if (i > 0)
                        {
                            typeNameBuilder.Append(",");
                        }
                        string parameterTypeName, parameterAssemblyName;
                        BindToName(genericParameters[i], out parameterAssemblyName, out parameterTypeName);
                        typeNameBuilder.AppendFormat("[{0}, {1}]", parameterTypeName, parameterAssemblyName);
                    }
                    typeNameBuilder.Append("]");
                    typeName = typeNameBuilder.ToString();
                }
                // To handle the rest of types
                else
                {
                    assemblyName = serializedType.Assembly.FullName;
                    if (IsFrameworkAssembly(serializedType.Assembly))
                    {
                        assemblyName = assemblyName.Replace("Version=4.0.0.0", "Version=2.0.0.0");
                    }
                    typeName = serializedType.FullName;
                }
            }
    
            public override Type BindToType(string assemblyName, string typeName)
            {
                return null;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET service that uses the ActiveMQ client. I have implemented a
I have a wcf service that uses the .net System.AddIns framework to load assemblies
Situation I have a client library that uses the Windows Azure AppFabric Service Bus
I Have an asp.net web service that uses an oracle database. It works when
We have an application that uses Lucene.NET within a windows service to reindex our
I have a WCF service that uses ODP.NET to read data from an Oracle
I have a program written in VB.NET which stops a service that uses file
I have .NET service (C#) that uses a couple of c++ libraries. I have
I have a WCF service that exposes a bunch of methods that return business
I have a WCF service that uses UserName authentication via ACS. This works great

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.