views:

937

answers:

1

This is a C# Asp.net MVC project.

I've currently got the Unity mappings set up in the global.asax.cs. I'd like to move the container setup from code, to the web.config.

All has gone fine with my own types, but now I need to translate this line :

container.RegisterInstance(System.Web.Security.Membership.Provider);

(All the other config lines are container.Register**Type**).

I don't get very far at all. If I even include

<typeAliases>
    <!-- others elided -->
    <typeAlias
    alias="MembershipProvider"
type="System.Web.Security.MembershipProvider, System.Web"></typeAlias>

it dies with a config error:

The value of the property 'type' cannot be parsed. The error is: Could not load file or assembly 'System.Web' or one of its dependencies. The system cannot find the file specified.

So that's pretty weird - it seems like it's not looking in the GAC to resolve it? Or System.Web is not in the appdomain yet?

If I manually copy System.Web to the bin folder I can proceed, and get to the crux of the issue : how do you RegisterInstance System.Web.Security.MembershipProvider --> System.Web.Security.Membership.Provider?

<type type="MembershipProvider" mapTo="System.Web.Security.Membership.Provider, System.Web"></type>

gives :

Could not load type 'System.Web.Security.Membership.Provider' from assembly 'System.Web'.

as expected, since it's not a type.

Thanks for any pointers.

+2  A: 

have you tried the longer Assembliy reference ?

System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

So in your case you would have a line like

<type type="MembershipProvider" mapTo="System.Web.Security.MembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"></type>

Also woth mentioning that you had a . in the middle of "MembershipProvider" in your second example.

Saint Gerbil
That was the ticket!!! :-)
REA_ANDREW