I need to run workflow XAML, but that workflow keeps references to other XAMLs. When I'm trying to run the workflow by
ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings
{
CompileExpressions = true
};
return ActivityXamlServices.Load(stream, settings);
I get next error from Load method:
CacheMetadata for activity 'MyNamespace.MyMainActivity' threw 'System.Xaml.XamlObjectWriterException: Cannot create unknown type '{clr-namespace:MyNamespace}MyNestedActivity'.
How can I solve it?
I think you have to convert your internal xamls to dll (assembly) file. And load the assembly file while reading/loading the parent xaml.
System.Xaml.XamlXmlReaderSettings xmlsettings = new System.Xaml.XamlXmlReaderSettings();
if(dllFile != null) {
Assembly wfAssembly = Assembly.Load(dllFile);
xmlsettings.LocalAssembly = wfAssembly;
}
System.IO.StringReader stringReader = new System.IO.StringReader(xaml);
XamlXmlReader reader = new XamlXmlReader(stringReader, xmlsettings);
ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings { CompileExpressions = true };
Activity activity = System.Activities.XamlIntegration.ActivityXamlServices.Load(reader, settings);
hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.