WF4 RC - Cannot create unknown type when loading WF Service from loose Xaml with ActivityXamlServices

倾然丶 夕夏残阳落幕 提交于 2019-11-30 13:41:17

Short answer - Xaml load can't infer the local (default) assembly, so you need to specify it on XamlReaderSettings.LocalAssembly.

Open source code of the activity. Change "xmlns:local="clr-namespace:DeclarativeServiceLibrary1" to xmlns:local="clr-namespace:DeclarativeServiceLibrary1;assembly=DeclarativeServiceLibrary1".

You're deserializing the xaml file directly, but it is referencing a type (CodeActivity1) that is compiled as a CLR type into the DeclarativeServiceLibrary1 assembly. The most obvious answer is that the DeclarativeServiceLibrary1 assembly is not available to the console app at runtime. Make sure that this assembly is copied into the folder where you are running the console app (\bin\debug) and see if that makes a difference.

The bottom line is that even though you are reading the xaml file directly, it still needs access to any types that it references.

By looking at your code I can tell that you should have loaded a WorkflowService instead of a simple activity. There are basically two options to try here:

Option 1: Load the activity and host it inside a generated workflow service.

You can do this by loading the activity as normal and use the following snippet to make it into a workflow service instance:

WorkflowService service = new WorkflowService();
service.Body = loadedActivity;

After that you can host it inside the workflow service host.

Option 2: Load the workflow service directly

The second option is not much different from what you have now. But instead of using the ActivityXamlServices class you will need to use the XamlServices class to load the workflow service. After that it's a matter of firing up the workflow service host with the settings you used in your sample.

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