WF4 的序列化问题
我的工作流程服务中的变量有一个特殊问题。它是来自 REST 服务 ContactContract[]
的数据契约数组。当该数组为空时,一切都很好,并且工作流程可以正确继续。但是,如果数组中有任何项目在我的活动之外发生堆栈溢出,不幸的是我无法查明具体位置。
因此,当对象图中存在循环时,我之前在 DataContractSerializer 中看到过类似的情况,因此我编写了一个单元测试来尝试一下。测试失败,但出现以下异常:
System.Xaml.XamlObjectReaderException:无法序列化类型 “系统.运行时.序列化.扩展数据对象”。验证 类型是公共的,并且具有默认构造函数或实例 描述符。
测试:(
[TestMethod]
public void ContactArraySerialize()
{
var ser = new DataContractSerializer(typeof(ContactContract[]));
var reader = new StringReader(Strings.SERIALIZED_CONTACT_LIST);
var xmlReader = XmlReader.Create(reader);
var list = ser.ReadObject(xmlReader) as ContactContract[];
var str = XamlServices.Save(list);
}
我会为联系人列表添加 xml,但它很大)
我认为这是因为合约实现了 IExtensibleDataObject 来更好地支持版本控制。
这不是我预期的堆栈溢出,但我打赌它是相关的。
有没有人遇到过这些问题或有任何建议?
I have a peculiar issue with a variable in my workflow service. It is an array of a datacontract from a REST service, ContactContract[]
. When this array is empty everything is great and the workflow continues on correctly. However, if there are any items in the array a stack overflow occurs outside of my activities, I can't pinpoint the specific spot unfortunately.
So, having seen something like this before with the DataContractSerializer
when cycles exist in the object graph I wrote a unit test to try it out. The test fails with the following exception:
System.Xaml.XamlObjectReaderException: Unable to serialize type
'System.Runtime.Serialization.ExtensionDataObject'. Verify that the
type is public and either has a default constructor or an instance
descriptor.
And the test:
[TestMethod]
public void ContactArraySerialize()
{
var ser = new DataContractSerializer(typeof(ContactContract[]));
var reader = new StringReader(Strings.SERIALIZED_CONTACT_LIST);
var xmlReader = XmlReader.Create(reader);
var list = ser.ReadObject(xmlReader) as ContactContract[];
var str = XamlServices.Save(list);
}
(I would add the xml for the contact list but it's huge)
I gather this is because the contract implements IExtensibleDataObject
to support versioning a bit better.
This is not the stack overflow I had anticipated, but I bet it is related.
Has anyone encountered either of these issues or have any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我现在感觉自己像个白痴。事实证明,不是工作流程崩溃,而是 WcfTestClient b/c 无法弄清楚如何显示联系人合同。
Ok I feel like an idiot now. Turns out it wasn’t the workflow crashing but the WcfTestClient b/c it couldn’t figure out how to display the contact contract.