例外:ComponentActivator:不能代理AsFactoryImplementation< FactoryType> [英] Exception : ComponentActivator: could not proxy AsFactoryImplementation.<FactoryType>

查看:1472
本文介绍了例外:ComponentActivator:不能代理AsFactoryImplementation< FactoryType>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这$ C $下实现厂温莎城堡,但它会抛出和异常如在这个问题上的标题。我下面的文档的例子这里。 PLZ指出哪里我收到错误的。

I tried this code for implement the Factory in castle windsor, but it throws and exception as shown in title of this issue. i am following the examples of Documentation here. plz point out where i am getting wrong.

using System;
using System.Windows.Forms;
using Castle.Facilities.TypedFactory;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Castle.MicroKernel.Registration;
using Castle.Windsor;

namespace AsFactoryImplementation
{
interface IDummyComponnentFactory
{
    IDummyComponnent creat();
    void Relese(IDummyComponnent factory);
}

interface IDummyComponnent
{
    void show();
}

class DummyComponnent:IDummyComponnent
{
    public void show()
    {
        Console.WriteLine("just testing this for better performance");
    }
}

class Program:WindsorContainer
{
    static void Main(string[] args)
    {
        var container = new WindsorContainer();
        container.AddFacility<TypedFactoryFacility>();

        container.Register(Component.For<IDummyComponnent>().ImplementedBy<DummyComponnent>().Named("FirstConnection").LifeStyle.Transient
            ,Component.For<IDummyComponnentFactory>().AsFactory());

        var val = container.Resolve<IDummyComponnent>();
        val.show();

        var val2 = container.Resolve<IDummyComponnentFactory>();

    }
}

}

推荐答案

是不是内部异常解释的不够好?

Isn't the inner exception explaining it well enough?

键入 AsFactoryImplementation.IDummyComponnentFactory 是不可见的   DynamicProxy。无法为不可访问的类型创建代理。   使公众型或内部和标记您的程序集    [总成:   InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)]   属性。

Type AsFactoryImplementation.IDummyComponnentFactory is not visible to DynamicProxy. Can not create proxy for types that are not accessible. Make the type public, or internal and mark your assembly with [assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] attribute.

这篇关于例外:ComponentActivator:不能代理AsFactoryImplementation&LT; FactoryType&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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