나는 클래스 라이브러리에 정의 된 클래스가 있습니다. 지금은 클래스 내부의 정적 메서드를 호출하는 활동 안에 InvokeMethod
활동을 사용하고자하지만, 디버거는 말한다 런타임 예외가 발생합니다 :.NET의 워크 플로 활동에서 외부 클래스를 사용하는 방법? 나는 또한 <code>XAML</code> 파일에 정의 된 <code>Activity</code>이</p> <pre><code>namespace TestLib { public class TestClass { public static void Test() { } } } </code></pre> <p>:
"Could not load file or assembly 'TestLib, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
클래스 라이브러리가 제대로 참조 내가 XAML 소스의 것을 볼 수 있습니다 , 너무. 이 클래스를 소스에 포함하면 제대로 작동합니다.
워크 플로에서 외부 형식을 사용하는 올바른 방법과 내가 잘못하고있는 것은 무엇입니까? 감사.
업데이트 :
이 사례 재 작성은 매우 간단합니다.
TestLib
이라는 Class Library
프로젝트를 만들고 위의 TestClass
을 추가하십시오.
Activity Library
프로젝트를 만들고 주 활동의 이름을 TestActivity
으로 바꿉니다. TestLib
에 대한 참조를 추가하십시오. 내부에 InvokeMethod
액티비티로 Sequence
액티비티를 추가 한 다음이를 사용하여 TestClass.Test
메서드를 호출합니다.
<Activity mc:Ignorable="sap sap2010 sads" x:Class="WorkflowSimpleTest.TestActivity" sap2010:ExpressionActivityEditor.ExpressionActivityEditor="C#" sap2010:WorkflowViewState.IdRef="WorkflowSimpleTest.Activity1_1"
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
xmlns:t="clr-namespace:TestLib;assembly=TestLib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextExpression.NamespacesForImplementation>
<sco:Collection x:TypeArguments="x:String">
<x:String>System</x:String>
<x:String>System.Collections.Generic</x:String>
<x:String>System.Data</x:String>
<x:String>System.Linq</x:String>
<x:String>System.Text</x:String>
</sco:Collection>
</TextExpression.NamespacesForImplementation>
<TextExpression.ReferencesForImplementation>
<sco:Collection x:TypeArguments="AssemblyReference">
<AssemblyReference>Microsoft.CSharp</AssemblyReference>
<AssemblyReference>System</AssemblyReference>
<AssemblyReference>System.Activities</AssemblyReference>
<AssemblyReference>System.Core</AssemblyReference>
<AssemblyReference>System.Data</AssemblyReference>
<AssemblyReference>System.Runtime.Serialization</AssemblyReference>
<AssemblyReference>System.ServiceModel</AssemblyReference>
<AssemblyReference>System.ServiceModel.Activities</AssemblyReference>
<AssemblyReference>System.Xaml</AssemblyReference>
<AssemblyReference>System.Xml</AssemblyReference>
<AssemblyReference>System.Xml.Linq</AssemblyReference>
<AssemblyReference>mscorlib</AssemblyReference>
<AssemblyReference>TestLib</AssemblyReference>
<AssemblyReference>WorkflowSimpleTest</AssemblyReference>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<Sequence sap2010:WorkflowViewState.IdRef="Sequence_1">
<InvokeMethod sap2010:WorkflowViewState.IdRef="InvokeMethod_1" MethodName="Test" TargetType="t:TestClass" />
<WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_1" Text="End activity." />
<sads:DebugSymbol.Symbol>d1dEOlxFbHZlZGluXFByb2plY3RzXEF1dG9tYXRpb24mQklcc291cmNlXFNFQ1VSSVRBU1xXb3JrZm9sd1NpbXBsZVRlc3RcVGVzdEFjdGl2aXR5LnhhbWwEJgMqDgIBAScFJ3ECAQQoBShVAgECKEMoUgIBAw==</sads:DebugSymbol.Symbol>
</Sequence>
<sap2010:WorkflowViewState.ViewStateManager>
<sap2010:ViewStateManager>
<sap2010:ViewStateData Id="InvokeMethod_1" sap:VirtualizedContainerService.HintSize="218,130" />
<sap2010:ViewStateData Id="WriteLine_1" sap:VirtualizedContainerService.HintSize="218,62" />
<sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="240,356">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="WorkfolwSimpleTest.Activity1_1" sap:VirtualizedContainerService.HintSize="280,436" />
</sap2010:ViewStateManager>
</sap2010:WorkflowViewState.ViewStateManager>
</Activity>
은 콘솔 응용 프로그램을 작성하고이 코드를 사용하여 워크 플로우를 실행합니다 :
Dictionary<string, object> vars = new Dictionary<string, object>() { };
WorkflowApplication wfApp = new WorkflowApplication(new TestActivity(), vars);
wfApp.Completed += delegate (WorkflowApplicationCompletedEventArgs e)
{
Console.WriteLine("Completed.");
};
wfApp.Idle += delegate (WorkflowApplicationIdleEventArgs e1)
{
Console.WriteLine("Idle.");
};
wfApp.Run();
응용 프로그램은 런타임 예외를 발생한다이 XAML
코드입니다.
더 많은 코드를 추가 할 수 있습니까? 아마도 InvokeMethod와 다른 중요한 것들을 사용할 수 있습니까? –
@ J.Pichardo 질문을 업데이트했습니다. –