RegisterTypeMapping Fails

Jun 4, 2008 at 8:06 PM
I am stuck.   Why would the following line fail in the module initializer?:

container.RegisterTypeMapping<

IPmtStateManager, PmtStateManager>();

The implementation class inherits from the interface provided.  I am not able to fiund any documentation on this issue.  The only thing that is different about this as opposed to a controller registration is that the interface and the implementation are in separate assemblies, and namespaces.

Any ideas?

 

Jun 5, 2008 at 5:14 AM
I am answering from memory, as I am at home on a computer with only games installed, no dev environment, so I may be mistaken.  However, I recall that when i was working on one of my recent blog posts adding Unity support to CWAB, I had to switch the order of the types in all the calls to RegisterTypeMapping.  In Unity, it is <InterfaceType, ConcreteType>, but in CWAB it is <ConcreteType, InterfaceType>.  Why?  Different teams at different times with different experiences.... 

Try switching the order of the types in the call.

Good luck,
Michael Puleio -- patterns & practices
Blog -- http://blogs.msdn.com/mpuleio
Jun 6, 2008 at 6:11 PM
For the service, it is:

service.AddNew<concreteType,InterfaceType>();

For the type mapping, it is

container.RegisterTypeMapping<InterfaceType, concreteType>();


If the interface type and it's implemening type are at different assemblies, I think this should be working

container.RegisterTypeMapping(Type.GetType("Interface full type name, the assembly name"), Type.GetType("Implementing full type name, the assembly name") );


Chester in Calgary
Jun 9, 2008 at 10:18 PM


rusdawg400 wrote:
I am stuck.   Why would the following line fail in the module initializer?:

container.RegisterTypeMapping<

IPmtStateManager, PmtStateManager>();

The implementation class inherits from the interface provided.  I am not able to fiund any documentation on this issue.  The only thing that is different about this as opposed to a controller registration is that the interface and the implementation are in separate assemblies, and namespaces.

Any ideas?

Was the failure at compile or runtime?  What was the error message?   Thought...   Although you have a valid reference to an assembly (font color turns cyan) it may be that the referenced assembly has dependencies on other assemblies that must also be referenced in your current project.
Jun 10, 2008 at 2:41 AM
It turns out that the reason I was having trouble is that I was not aware that you needed to switch the calls around.  Appearantly I was trying to call a [CreateNew] on  an object that was not registered yet...Sorry for the post.

R-Diddy