user3497702
user3497702

Reputation: 841

Updating Nuget related Unity to latest cause error on WebAPIConfig Registration

There is an .Net solution that contains .Net 4.7.1 MVC Web App and .Net Core 8.0 Library and Web API. Updated Unity and its related NuGet PAckage as given below.

Unity.5.8.5 -> Unity.5.11.10 and related Nuget 
Unity.Abstractions 3.30 -> Unity.Abstractions 5.11.7
Unity.Mvc.5.0.13 -> Unity.Mvc.5.11.1
Unity.Container.5.8.5 -> Unity.Container.5.11.11
Unity.WebAPI 5.3.0 -> Unity.WebAPI 5.4.0


private void RegisterGenericAndOtherTypes(IUnityContainer 
 container)
{
var contextOptions = DBConfig.EFCoreConnectionOptions();

container.RegisterType<IContext, XYZContext>(new 
classname1(), new InjectionConstructor(contextOptions));
}

It gives error in WebAPIConfig as given below

Error   CS1503  Argument 2: cannot convert from 'ProjectName.classname1' 
to 'Unity.Injection.InjectionMember'

I dont want to revert the update so advise accordingly.

Upvotes: 0

Views: 34

Answers (1)

mamift
mamift

Reputation: 927

So the issue I think is where you have:

container.RegisterType<IContext, XYZContext>(new classname1(), new InjectionConstructor(contextOptions));

The method signature has changed in the updated version; try taking out the first argument, new classname1(), and change the method call to be:

container.RegisterType<IContext, XYZContext>(new InjectionConstructor(contextOptions));

Upvotes: 0

Related Questions