如何强制工作流包含本地类型程序集名称? [英] How to mandate workflows to include local types assembly name?
问题描述
我正在使用 WF4 并且在同一个项目中拥有我的类型、活动和工作流,然后我使用 ActivityXamlServices.Load(path) 加载我的工作流活动,它抛出以下异常:
I am using WF4 and am having my types, activities and workflows in the same project and then I am using ActivityXamlServices.Load(path) to load my workflow activity and it throws the following exception:
The type ‘InArgument(local:,,,, of property ‘InputArgs’ could not be resolved
通过查看此问题的解决方案 post,我在工作流中手动包含程序集名称,一切正常.
By looking at the solution to this problem at this post, I included assembly name manually in the workflow, and it all works.
问题:每次我对工作流程进行任何更改时,它都会重新编写 xaml 并删除我手动添加的程序集名称.
Problem: Everytime I make any change in the workflow, it re-writes the xaml and removes the assembly names I manually added.
问题:有没有办法强制包括本地类型的程序集名称?
Question: Is there a way to mandate including assembly names of local types also?
推荐答案
诀窍是使用 XamlXmlReaderSettings 并指定应该用作本地程序集引用的内容.
The trick is to use a XamlXmlReaderSettings and specify what should be used as the local assembly reference.
var settings = new XamlXmlReaderSettings()
{
LocalAssembly = typeof(YourArgumentType).Assembly
};
var reader = new XamlXmlReader(path, settings);
Activity workflow = ActivityXamlServices.Load(reader);
这篇关于如何强制工作流包含本地类型程序集名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!