工作流程4持久性,反序列化错误 [英] Workflow 4 Persistence, deserialization error

查看:93
本文介绍了工作流程4持久性,反序列化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有一个WF4活动,我已成功将其持久保存到Sql数据库,但是当尝试加载以前保存的实例时,我收到以下异常:

反序列化程序无法加载要反序列化的类型,因为在程序集中找不到类型"System.Activities.Location`1 [[MYTYPE,MYASSEMBLY,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null]]" System.Activities,版本= 4.0.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35''.检查要序列化的类型与要反序列化的类型具有相同的协定,并使用相同的程序集.

"MYTYPE"类是MYASSEMBLY中包含的POCO.

感谢收到的任何帮助,


谢谢

Hi all

I have a WF4 activity which I am successfully persisting to an Sql database, however when attempting to load the previously persisted instance I receive the following exception:

The deserializer cannot load the type to deserialize because type ''System.Activities.Location`1[[MYTYPE, MYASSEMBLY, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'' could not be found in assembly ''System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35''. Check that the type being serialized has the same contract as the type being deserialized and the same assembly is used.

The "MYTYPE" class is a POCO contained within MYASSEMBLY.

Any help gratefully received,


Thanks

推荐答案

水合过程需要找到您的装配体,而找不到.最简单的方法是对程序集进行签名,然后将其放入GAC中.

如果您喜欢冒险,可以处理AssemblyResolve事件并像这样自己加载程序集:

The hydration process needs to find your assembly and can''t. The easiest thing to do is sign your assembly and put it in the GAC.

If you are adventurous you can handle the AssemblyResolve event and load assemblies yourself like this :

private Assembly AppDomain_AssemblyResolve(object sender, ResolveEventArgs e)
{
   if (e.Name == "MYTYPE, MYASSEMBLY, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
   {
       return Assembly.Load("MYTYPE, MYASSEMBLY, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
   }

   return null;
}


这篇关于工作流程4持久性,反序列化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆