diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs index 10a7712..09ae1e3 100644 --- a/LightweightIocContainer/IocContainer.cs +++ b/LightweightIocContainer/IocContainer.cs @@ -227,7 +227,14 @@ public class IocContainer : IIocContainer, IIocResolver /// Getting resolve stack failed without exception internal (bool success, object resolvedObject, Exception? exception) TryResolveNonGeneric(Type type, object?[]? arguments, List? resolveStack, bool isFactoryResolve = false) { - object? resolvedValue = GenericMethodCaller.CallPrivate(this, nameof(TryResolve), type, arguments, resolveStack, isFactoryResolve); + MethodInfo? method = typeof(IocContainer).GetMethod(nameof(TryResolve), BindingFlags.NonPublic | BindingFlags.Instance); + MethodInfo? genericMethod = method?.MakeGenericMethod(type); + + if (genericMethod == null) + throw new GenericMethodNotFoundException(nameof(TryResolve)); + + object? resolvedValue = genericMethod.Invoke(this, new object?[]{arguments, resolveStack, isFactoryResolve}); + if (resolvedValue is not ValueTuple resolvedTuple) throw new Exception("Invalid return value!");