Tinyioc: Registering Open Generic Types Fails

Created on 26 Aug 2011  ·  5Comments  ·  Source: grumpydev/TinyIoC

Attempting to Register:

Register(typeof(IThing<>), typeof(DefaultThing<>)).AsSingleton();

fails with:
TinyIocRegistrationException : Type DefaultThing1 is not valid for a registration of type IThing1
----> System.ArgumentException : Invalid generic arguments
Parameter name: typeArguments

Most helpful comment

This is currently keeping me from using TinyIoC with MediatR. I need to do something like this to hookup MediatR:

container.Register(typeof (IRequestHandler<,>));

But I'm receiving the error, abstract classes or interfaces are not valid implementation types for SingletonFactory. Any chance this could be addressed?

All 5 comments

@cmckeegan:

Started work on this here:

https://github.com/grumpydev/TinyIoC/tree/OpenGenerics

Currently a few things are broken (but fixable), but there's now a passing test that registers IThing<> with RealThing<> and resolves IThing to RealThing.

Have you merged it into the master brunch yet?

@JoergEg yes, it's in master, but it's currently limited to single manual registrations, need to do more work to automatically scan/register multiple registrations.

Is this really still open?

This is currently keeping me from using TinyIoC with MediatR. I need to do something like this to hookup MediatR:

container.Register(typeof (IRequestHandler<,>));

But I'm receiving the error, abstract classes or interfaces are not valid implementation types for SingletonFactory. Any chance this could be addressed?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinkuszyk picture kevinkuszyk  ·  3Comments

DmitryEfimenko picture DmitryEfimenko  ·  3Comments

jfrueh picture jfrueh  ·  3Comments

DamianEdwards picture DamianEdwards  ·  3Comments

phillip-haydon picture phillip-haydon  ·  3Comments