为什么我们在一些机器上,但不是别人得到一个WCF“帧错误”
-
25-09-2019 - |
题
我们刚刚发现,我们正在“帧错误的”运行我们的一些客户在测试机上系统时,(所报告的WCF日志)。
这一切工作确定我们的发展的机器。
我们有一个抽象基类,有KnownType所有它的子类的属性。其中它的子类的它缺少的DataContract属性。
然而,它所有的工作我们的测试机上!
在顾客试机,我们得到了“帧错误” 显示出来的WCF日志,这不是错误消息,缺少一个DataContract属性,当我在过去看到的,或KnownType属性
我希望去的这条底线, 因为我们不能再有信心 我们之前测试系统的能力 它给客户,直到我们可以 让我们的机器的行为有的 客户的机器上。
代码,试图说明什么,我说什么,(不是真正的代码)
[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 } });
}
}
更新我已经告诉了.NET 3.5 SP1是在所有的机器,我还没有comfirm这个自己。
解决方案 2
我相信问题是,有些机器没有3.5的 SP1 在他们身上。
其他提示
我们也有类似的问题:文件是正确的我们所有的测试机器数据契约反序列化。然而,一个特定的客户机上,它失败,错误
类名无法序列。考虑与
DataContractAttribute
属性将其标记和标记所有你想用DataMemberAttribute
属性连载成员。
原来,cusotmer正在运行的.NET Framework 3.0,而我们所有的测试已经在.NET Framework 3.5 SP1中完成。
似乎数据契约串行器的行为是翻过的.NET Framework 3.0和.NET Framework 3.5不同。在3.5,如果一个类是XML序列化的,那么它是自动数据合同序列化也。然而,这是不与框架3.0的情况下 - 类已经与[DataContract]
或[Serializable]
待装饰
希望这有助于!