So I have the following line of code in c# to register AutoMapper with SimpleInjector:
container.Register(() => config.CreateMapper(container.GetInstance));
For context, config.CreateMapper() looks like this:
public IMapper CreateMapper(Func<Type, object> serviceCtor);
While container.GetInstance looks like this:
public object GetInstance(Type serviceType);
The first line of code I posted works in C# because config.CreateMapper takes in a function that takes a type of Type and returns a type of object. Exactly what container.GetInstance does.
When I try to do this same line in VB, as:
container.Register(Function() config.CreateMapper(container.GetInstance))
It gives an error Type arguments for 'Public Function Container.GetInstance(Of TService)()' cannot be inferred from the usage. Try specifying type arguments explicitly. It is giving this error because container.GetInstance has an overload that looks like this:
public TService GetInstance<TService>() where TService : class;
Why does the VB try to use the wrong overload of GetInstance and how can I force it to use the correct one?