How to mandate workflows to include local types assembly name?

懵懂的女人 提交于 2019-12-13 00:58:52

问题


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

By looking at the solution to this problem at this post, I included assembly name manually in the workflow, and it all works.

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?


回答1:


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);


来源:https://stackoverflow.com/questions/14390131/how-to-mandate-workflows-to-include-local-types-assembly-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!