Syntax For Generic Type Declarations In Type Elements

I was recently working on implementing a provider based design for a project I'm working on which also happens to make heavy use of generics throughout the provider architecture. The signature of the type to be used in the <providers> section of the config file is MyType<T, V>, however I kept getting the dreaded "Unable to load type 'MyType' from assembly 'MyAssembly'" error when attempting to run the application. After about 30 minutes of wringing my hands wondering what the heck was going on, I remembered that generic types have a different signature when declared in text form. The fix was simple, instead of declaring it as

type="MyAssembly.MyType, MyAssembly"

This needs to be changed to

type="MyAssembly.MyType`2, MyAssembly"

Where the number after the '`' is the number of generic type parameters in the type's signature. It would have been nice if the runtime could have offered a hint like it does in other situations. This may be generics 101 for some, but I'm posting this in hopes it'll save someone else some time if Google picks up the keywords in this post.


# Erik Lane said:

Giddy Up!  Thanks for the tip.

Thursday, June 21, 2007 10:16 AM