“XamlInjector–Cannot create unknown type errors"的解决方案;不起作用 [英] Solution for "XamlInjector–Cannot create unknown type errors" does not work

查看:21
本文介绍了“XamlInjector–Cannot create unknown type errors"的解决方案;不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在单元测试中,我将自定义活动的程序集作为本地程序集传递给了ctorvar xamlInjector = new XamlInjector("CreditAtRenewalFlow.xaml", typeof(CreateFollowUp).Assembly);

In unit test, i passed the assembly of Custom Activity to the ctor as the local assembly var xamlInjector = new XamlInjector("CreditAtRenewalFlow.xaml", typeof(CreateFollowUp).Assembly);

CreateFollowUp 是一个 AsynCodeActivity

我在解析规则 'Element ::= . EmptyElement | ( StartElement ElementBody ) 中遇到错误'意外的 'PROPERTYELEMENT'.'.'行号 '2' 和行位置 '4'."在执行以下行时

I got error "'Unexpected 'PROPERTYELEMENT' in parse rule 'Element ::= . EmptyElement | ( StartElement ElementBody ).'.' Line number '2' and line position '4'." at execution of the following line

var host = WorkflowInvokerTest.Create(xamlInjector.GetActivity());

单元测试的样本是[TestMethod][DeploymentItem(@"src\ProcessFlows\Activity1.xaml")]公共无效 Activity1Test(){

The sample of the unit test is [TestMethod] [DeploymentItem(@"src\ProcessFlows\Activity1.xaml")] public void Activity1Test() {

    var xamlInjector = new XamlInjector("Activity1.xaml", typeof(CreateFollowUp).Assembly);
    xamlInjector.ReplaceAll(typeof(CreateFollowUp), typeof (MockCreateFollowUp));

    var mockExternalServiceManager = new Mock<IExternalServices>();
    mockExternalServiceManager.Setup(x => x.CreateFollowUp()).Verifiable();

    var host = WorkflowInvokerTest.Create(xamlInjector.GetActivity());

    dynamic parameterValues1 = new WorkflowArguments();
    parameterValues1.value1 = mockExternalServiceManager.Object;

    IDictionary<string, object> dictionary = host.TestActivity();

   }

下面给出了 CreateFollowUp

And the CreateFollowUp is given below

公共密封类 CreateFollowUp : AsyncCodeActivity{
[必需参数]公共 InArgument ExternalServices { 获取;放;}

public sealed class CreateFollowUp : AsyncCodeActivity {
[RequiredArgument] public InArgument ExternalServices { get; set; }

    protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback,

对象状态){操作 createFollowUp = this.ExternalServices.Get(context).CreateFollowUp;context.UserState = createFollowUp;返回 createFollowUp.BeginInvoke(callback, state);}

object state) { Action createFollowUp = this.ExternalServices.Get(context).CreateFollowUp; context.UserState = createFollowUp; return createFollowUp.BeginInvoke(callback, state); }

    protected override void EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
    {
        var createFollowUp = context.UserState as Action;
        if (createFollowUp == null)
        {
            throw new ArgumentNullException("The AsyncState of the IAsyncResult was not of the type

ExternalServices.AsyncCreateFollowUp.", (Exception)null);}

ExternalServices.AsyncCreateFollowUp.", (Exception)null); }

        createFollowUp.EndInvoke(result);
    }
}

推荐答案

尝试修改活动的源代码.将 "xmlns:local="clr-namespace:Activity1" 更改为 xmlns:local="clr-namespace:Activity1;assembly=Activity1".

try to modify source code of the activity. Change "xmlns:local="clr-namespace:Activity1" to xmlns:local="clr-namespace:Activity1;assembly=Activity1".

在命名空间引用中包含程序集(使用正确的程序集名称)

include the assembly in namespaces references (use the correct assembly name)

这篇关于“XamlInjector–Cannot create unknown type errors"的解决方案;不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆