0

DryIoc can't seem to Resolve a IAsyncRequestHandler.
It throws
"An exception of type 'DryIoc.ContainerException' occurred in DryIoc.dll but was not handled in user code Additional information: Unable to resolve MediatR.IRequestHandler. Where no service registrations found and number of Rules.FallbackContainers: 0 and number of Rules.UnknownServiceResolvers: 0"
which is weird because it should be resolving a IAsyncRequestHandler.
Another weird thing is that the code runs well on Net.Fiddle (check here)

I'm using VS 2015 Update 3 in Windows 10 Home, MediatR 3.0.0, DryIoc.dll 2.10.0, .Net framework 4.5 (also tried with 4.6.1).

Am I registering it in a wrong way? This should be straightforward.

Related: What is the best way to register all handlers?

DMVC
  • 240
  • 1
  • 2
  • 15
  • Did you try to use this example from MediatR repo https://github.com/jbogard/MediatR/blob/master/samples/MediatR.Examples.DryIoc/Program.cs – dadhi Feb 11 '17 at 18:51
  • Yes, along with some other articles. I Just can't figure out the reason for the exception. Did you find anything wrong in the Net.Fiddle code that could explain the exception? What about the best way to register all IAsyncRequestHandler<> and IAsyncRequestHandler<,> automatically? – DMVC Feb 11 '17 at 19:25
  • Did you try RegisterMany with your handlers assemblies as in example? – dadhi Feb 11 '17 at 19:31
  • Ok, I found the problem in my code. Thanks. Regarding the RegisterMany question: Isn't it registering all Interfaces found in both assemblies? Suppose I just want to register automatically IAsyncRequestHandler interfaces? – DMVC Feb 11 '17 at 19:38
  • You can filter interfaces you need in condition. – dadhi Feb 11 '17 at 19:39
  • Ok, I've managed to register only the IAsyncRequestHandler using `container.RegisterMany(new[] { GetType().GetAssembly()}, type => type.IsGenericType && type.GetGenericTypeDefinition() == typeof (IAsyncRequestHandler<,>));`. But I'm stuck with MediatR 2.1.0. MediatR 3.0.0 keeps throwing the mentioned exception. – DMVC Feb 11 '17 at 22:11
  • I don't know, they did some breaking changes in MediatR 3. And did not yet have a chance to play with it. Given that dotnetfiddle works, it may be something in your setup, e.g. two dlls where you would expect one, or some type being internal instead of public, etc. – dadhi Feb 12 '17 at 13:14

0 Answers0