Registration difficulties

Oct 4, 2011 at 1:39 PM

I have downloaded and ionstalled the latest version, but can;t seem to get it to work.

I have an MVC application that does standard registration as  

 Container.RegisterType<IModel,Model>();

Later ..    

 Container.Resolve(typeof(IModel));

This works fine but fails when I try to use AutoRegistration instead, as follows

Container
        .ConfigureAutoRegistration()
        .LoadAssembliesFrom(Assembly.GetExecutingAssembly().location)
        .ExcludeSystemAssemblies()
        .ExcludeAssemblies(a=>!a.FullName.StartsWith("MyCompany.Product")
        .Include(If.ImplementsITypeName, Then.Register().WithTypeName())
        .ApplyAutoRegistration();
 

 However, when I step through the code I can see the registration logic execute  IModel and it's related Model

_registrationEntries.Add(new RegistrationEntry(
typeFilter,
(t, c) => {
registrationOptions.Type = t;
foreach (var contract in registrationOptions.Interfaces) {
c.RegisterType( contract, t, registrationOptions.Name, registrationOptions.LifetimeManager);
}
}, _container
));

I must be doing something wrong.  

Oct 5, 2011 at 11:39 AM

You're registering your types with name (and IIRC to resolve them you have to supply the name), what you probably want is just:

.Include(If.ImplementsITypeName, Then.Register())

In this case 

Container.Resolve(typeof(IModel));

should work for you.