public static class ContainerExtensions { public static Delegate GetMessageHandlerForMessage(this ILifetimeScope lifetimeScope, object message) { MethodInfo methodInfo = typeof(ContainerExtensions) .GetMethods(BindingFlags.Static | BindingFlags.NonPublic) .Single(m => m.Name == "GetMessageHandlerForMessageInternal"); var methodInfo2 = methodInfo.MakeGenericMethod(new[] { message.GetType() }); return (Delegate)methodInfo2.Invoke(null, new[] { lifetimeScope, message }); } private static Action GetMessageHandlerForMessageInternal(ILifetimeScope lifetimeScope, T message) { var commandHandler = lifetimeScope.Resolve>(); return commandHandler.Handle; } }