के साथ ढीले एक्सएएमएल से डब्ल्यूएफ सेवा लोड करते समय अज्ञात प्रकार नहीं बना सकता है मैं गतिशील रूप से एक डब्ल्यूएफ 4 (आरसी) सेवा होस्ट करने की कोशिश कर रहा हूं। मेरे पास दो परियोजनाओं के साथ एक परीक्षण समाधान है। पहला एक घोषणात्मक वर्कफ़्लो सेवा लाइब्रेरी है जिसमें एक रूट फ्लोचार्ट गतिविधि है, और एक साधारण कस्टम कोड गतिविधि है। वर्कफ़्लो सेवा लाइब्रेरी किसी भी अन्य कस्टम असेंबली या संदर्भों पर निर्भर नहीं है। दूसरा मेरा होस्ट ऐप है, जो मेरे परीक्षण समाधान में सिर्फ एक कंसोल एप्लीकेशन है।डब्ल्यूएफ 4 आरसी - गतिविधि एक्सएएमएल सर्विसेज
मेरे होस्ट ऐप में, मैं वर्कफ़्लो सेवा के लिए Xaml को किसी गतिविधि में लोड करने के लिए ActivityXamlServices का उपयोग करने का प्रयास कर रहा हूं, और फिर उस गतिविधि का उपयोग करके वर्कफ़्लो इंस्टेंस को फायर करने के लिए वर्कफ़्लो सर्विसवर्कहोस्ट का उपयोग करें।
जैसे ही मैंने नई अप WorkflowServiceHost वस्तु की कोशिश करते हैं, मैं इस अपवाद मिलता है ...
Cannot create unknown type '{clr-namespace:DeclarativeServiceLibrary1}CodeActivity1'.
अगर मैं अपने फ़्लोचार्ट डिजाइनर से CodeActivity1 निकालने के लिए, सब कुछ ठीक चलता है। यदि मैं अपने होस्ट प्रोजेक्ट से वर्कफ़्लो सेवा प्रोजेक्ट का प्रत्यक्ष संदर्भ जोड़ता हूं और फिर Xaml से बनाई गई गतिविधि की बजाय मेरी फ़्लोचार्ट गतिविधि के उदाहरण का उपयोग करके वर्कफ़्लो सेवावॉस्ट बना देता हूं, तो यह भी ठीक काम करता है।
ऐसा लगता है कि गतिशील रूप से लोड होने पर किसी कारण से मेरी CodeActivity का उपयोग करना पसंद नहीं है।
किसी के पास कोई विचार है कि मैं अपनी वर्कफ़्लो सेवा को गतिशील रूप से क्यों नहीं बना सकता?
मेरे कोड इस प्रकार है ...
DeclarativeServiceLibrary1.Activity1.xaml ...
<Activity mc:Ignorable="sap" x:Class="DeclarativeServiceLibrary1.Activity1" sap:VirtualizedContainerService.HintSize="654,676" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:local="clr-namespace:DeclarativeServiceLibrary1" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Flowchart sad:XamlDebuggerXmlReader.FileName="C:\dev\test\MyWorkflow\DeclarativeServiceLibrary1\Activity1.xaml" sap:VirtualizedContainerService.HintSize="614,636">
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">False</x:Boolean>
<av:Point x:Key="ShapeLocation">270,2.5</av:Point>
<av:Size x:Key="ShapeSize">60,75</av:Size>
<av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 300,165</av:PointCollection>
</scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<Flowchart.StartNode>
<FlowStep x:Name="__ReferenceID0">
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<av:Point x:Key="ShapeLocation">172.5,165</av:Point>
<av:Size x:Key="ShapeSize">255,90</av:Size>
<av:PointCollection x:Key="ConnectorLocation">300,255 300,285 300,299.5</av:PointCollection>
</scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<p:Receive CanCreateInstance="True" sap:VirtualizedContainerService.HintSize="255,90" OperationName="MyOperation" ServiceContractName="MyContractName" />
<FlowStep.Next>
<FlowStep x:Name="__ReferenceID1">
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<av:Point x:Key="ShapeLocation">194.5,299.5</av:Point>
<av:Size x:Key="ShapeSize">211,61</av:Size>
<av:PointCollection x:Key="ConnectorLocation">300,360.5 300,390.5 300,399</av:PointCollection>
</scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<WriteLine sap:VirtualizedContainerService.HintSize="211,61" Text="Workflow started" />
<FlowStep.Next>
<FlowStep x:Name="__ReferenceID3">
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<av:Point x:Key="ShapeLocation">200,399</av:Point>
<av:Size x:Key="ShapeSize">200,22</av:Size>
<av:PointCollection x:Key="ConnectorLocation">300,421 300,451 300,479.5</av:PointCollection>
</scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<local:CodeActivity1 sap:VirtualizedContainerService.HintSize="200,22" />
<FlowStep.Next>
<FlowStep x:Name="__ReferenceID2">
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<av:Point x:Key="ShapeLocation">194.5,479.5</av:Point>
<av:Size x:Key="ShapeSize">211,61</av:Size>
</scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<WriteLine sap:VirtualizedContainerService.HintSize="211,61" Text="The code activity worked!" />
</FlowStep>
</FlowStep.Next>
</FlowStep>
</FlowStep.Next>
</FlowStep>
</FlowStep.Next>
</FlowStep>
</Flowchart.StartNode>
<x:Reference>__ReferenceID0</x:Reference>
<x:Reference>__ReferenceID1</x:Reference>
<x:Reference>__ReferenceID2</x:Reference>
<x:Reference>__ReferenceID3</x:Reference>
</Flowchart>
</Activity>
DeclarativeServiceLibrary1.CodeActivity1.cs ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
namespace DeclarativeServiceLibrary1
{
public sealed class CodeActivity1 : CodeActivity
{
// Define an activity input argument of type string
//public InArgument<string> Text { get; set; }
// If your activity returns a value, derive from CodeActivity<TResult>
// and return the value from the Execute method.
protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the Text input argument
//string text = context.GetValue(this.Text);
}
}
}
DeclarativeServiceLibrary1.Web। कॉन्फ़िगर करें ...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
ConsoleApplication1.Program.cs ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.Activities.XamlIntegration;
using System.ServiceModel;
using System.ServiceModel.Activities;
using System.ServiceModel.Description;
using System.Xaml;
using System.Reflection;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string baseAddress = @"http://localhost:8081/MyContractName";
string curDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string wfDefPath = Path.Combine(curDir, "Activity1.xaml");
Activity workflowActivity = (Activity)ActivityXamlServices.Load(wfDefPath);
WorkflowService service = new WorkflowService { Body = workflowActivity };
Uri serviceUri = new Uri(baseAddress, UriKind.Absolute);
WorkflowServiceHost host = new WorkflowServiceHost(service, new Uri[] { serviceUri });
host.Open();
//Display that we are listening on the console window
Console.WriteLine("Workflow '{0}' is listening at '{1}'", host.Activity.DisplayName, baseAddress);
Console.ReadLine();
}
}
}
मैं delarative कार्यप्रवाह सेवा है जो प्रतियां मेजबान कंसोल अनुप्रयोग के बिन \ डिबग \ फ़ोल्डर में विधानसभा और XAML फाइल पुस्तकालय में एक के बाद निर्माण घटना है।
धन्यवाद, टिम। मैंने XamlXmlReaderSettings.LocalAssembly का उपयोग करके xaml फ़ाइल में पढ़ने के लिए XamlXmlReader का उपयोग करने के लिए स्विच किया है जैसा आपने वर्णन किया है। ऐसा करना और XamlXmlReader को ActivityXamlServices.Load विधि में एक आकर्षण की तरह काम किया। – racingcow
वैकल्पिक रूप से आप एक्सएएमएल वर्कफ़्लो और उनके द्वारा उपयोग की जाने वाली गतिविधियों को विभाजित कर सकते हैं। जब आप ऐसा करते हैं, तो गतिविधि अब स्थानीय सीएलआर नेमस्पेस में नहीं है और इसे ठीक से लोड किया जाएगा। तो बस एक एक्सएएमएल वर्कफ़्लो-केवल प्रोजेक्ट और एक गतिविधि प्रोजेक्ट बनाएं। –
जैसा वर्णन किया गया है? –