![](/img/trans.png)
[英]NativeActivity in XAML loaded COMPILED workflow throws Expression Activity type 'CSharpValue1' requires compilation in order to run
[英]Run Workflow with nested XAML-activity
我需要運行工作流程XAML,但是該工作流程會保留對其他XAML的引用。 當我嘗試通過以下方式運行工作流程時
ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings
{
CompileExpressions = true
};
return ActivityXamlServices.Load(stream, settings);
我從加載方法中得到下一個錯誤:
活動'MyNamespace.MyMainActivity'的CacheMetadata拋出'System.Xaml.XamlObjectWriterException:無法創建未知類型'{clr-namespace:MyNamespace} MyNestedActivity'。
我該如何解決?
我認為您必須將內部xamls轉換為dll(匯編)文件。 並在讀取/加載父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);
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.