Configuration Files & Generics With a Where Clause

Nov 2, 2010 at 1:34 AM


I am trying to get a configuration file up and running with Unity.  My non-generic types work fine but when I try and add my generic (both open and closed) I get the following error:  The given assembly name or codebase was invalid.

Ordinarily I would check Fusion for the problem, but the thing is my non-generic types that are in the same assemblies work fine, and wiring up the configuration via code also works fine.  I have quadruple checked my assemblies and namespaces in the configuration file.  The only difference between what I am doing, and what samples I have seen in the help file online is that my generic types have a 'where TEntity : Entity' clause around them.

Here is a sanitized version:

<register type="MyNamespace.Contract.IUserCache, MyNamespace.Contract" mapTo="MyNamespace.Implementation.UserCache, MyNamespace.Implementation">




<lifetime type="transient"





<register type="MyNamespace.Contract.IEntityCache'1, MyNamespace.Contract" mapTo="MyNamespace.Implementation.EntityCache'1,MyNamespace.Implementation">

<lifetime type="transient" />


The first register works fine, the second register throws the exception.  I have a similar problem when I try and register a closed generic type.

I have tried versions using the square brackets, with, and instead of the '1(2, 3, etc..) notation but I get the same issue.  I have tried using my types as aliases but it doesn't seem to do anything.  Anyone got any pointers?

I apologize for nothing giving a more complete codebase, but it's not mine to give out.




Nov 5, 2010 at 6:20 AM

Interesting. It should work, I don't see anything obvious from here. I'm going to kick this over to the issue tracker so we don't lose track of this one and I can chase it down.



Nov 5, 2010 at 6:20 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.