.netwcfdatacontractknown-types

Why are we getting a WCF "Framing error" on some machines but not others


We have just found we are getting “framing errors” (as reported by the WCF logs) when running our system on some customer test machine.

It all works ok on our development machines.

We have an abstract base class, with KnownType attributes for all its sub classes. One of it’s subclass is missing it’s DataContract attribute.

However it all worked on our test machine!

On the customers test machine, we got “framing error” showing up the WCF logs, this is not the error message I have seen in the past when missing a DataContract attribute, or a KnownType attribute.

I wish to get to the bottom of this, as we can no longer have confidence in our ability to test the system before giving it to the customer until we can make our machines behave the some as the customer’s machines.


Code that try to show what I am talking about, (not the real code)

    [DataContract()]
    [KnownType(typeof(SubClass1))]
    [KnownType(typeof(SubClass2))] 
    // other subclasses with data members
    public abstract class Base
    {
        [DataMember]
        public int LotsMoreItemsThenThisInRealLife;
    }

    /// <summary>
    /// This works on some machines (not not others) when passed to Contract::DoIt, 
    /// note the missing [DataContract()]
    /// </summary>
    public class SubClass1 : Base
    {
        // has no data members
    }

    /// <summary>
    /// This works in all cases when passed to Contract::DoIt
    /// </summary>
    [DataContract()]
    public class SubClass2 : Base
    {
        // has no data members
    }

    public interface IContract
    {
        void DoIt(Base[] items);
    }

    public static class MyProgram
    {
        public static IContract ConntectToServerOverWCF()
        {
            // lots of code ...
            return null;
        }

        public static void Startup()
        {
            IContract server = ConntectToServerOverWCF();

            // this works all of the time
            server.DoIt(new Base[]{new SubClass2(){LotsMoreItemsThenThisInRealLife=2}});

            // this works "in develperment" e.g. on our machines, but not on the customer's test machines! 
            server.DoIt(new Base[] { new SubClass1() { LotsMoreItemsThenThisInRealLife = 2 } });
        }
    }

Update I have been told the .net 3.5 SP1 is on all the machines, I yet to comfirm this for myself.


Solution

  • I believe the problem is that some of the machine did not have 3.5 SP1 on them.