zcz527 / autofac

Automatically exported from code.google.com/p/autofac
Other
0 stars 0 forks source link

RegisterType WithParameter doesn't work #472

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I switched from Autofac 2 to Autofac 3 and getting a problem with code that is 
similiar to following:

    class TestModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType<HelloWorld>().AsSelf()
                .WithParameter(new NamedParameter("firstname", "John"))
                .WithParameter(new NamedParameter("lastname", "Doe"));
        }
    }

    public class HelloWorld
    {
        public HelloWorld(string firstname, string lastname)
        {  
        }
    }

The Problem is following: Argument type 'string [mscorlib, Version: 4.0.0.0 
Culture=neutral, ...] is not assignable to parameter type 'string [mscorlib, 
Version=2.0.5.0, Culture=neutral, ...].

I'm using .net 4. Is Autofac built against .net 2?

Thanks for every help

Original issue reported on code.google.com by heribert...@googlemail.com on 19 Nov 2013 at 4:19

GoogleCodeExporter commented 8 years ago
The .NET 2 "reference" is because Autofac is a portable class library. Chances 
are you need some patches on your machine to get portable class libraries to 
work.

We have a ton of unit tests around parameters so it is working; this very much 
looks like a PCL issue.

Check out this blog entry for some pointers and answers on PCL: 
http://www.paraesthesia.com/archive/2013/03/29/portable-class-library-answers.as
px

Original comment by travis.illig on 20 Nov 2013 at 12:03