Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I created a .NET ASP MVC 5 web app and installed Unity. A UnityConfig.cs created inside the App_Start folder of the app and I configured and registered the components I need.

Now I created another .NET ASP MVC 5 web application inside the same solution and I'm gonna use this one instead. I could not reinstall Unity because it already exists in the solution, I then copypasted the UnityConfig file from the old solution to the new one, inside the App_Start folder.

I'm on the UnityConfig file now and I get errors related to references: I installed the Unity.AspNet.Mvc reference but I can't find a way to find/install the Unity.Mvc5 reference, how can I solve this?

Can I fix the issue without uninstalling Unity and reinstalling it again?

What I have tried:

I did the following:

I right-clicked on the References of the new application folder, I selected "Add Reference" and typed "Unity.Mvc5" in the Search bar but I got no result...
Posted
Updated 27-Nov-20 0:52am

1 solution

Tools ⇒ NuGet Package Manager ⇒ Manage NuGet Packages for Solution...

Select the "Installed" page, and then select the Unity.Mvc5 package.

On the right-hand side, you'll see that the package is ticked for your old project, but not for your new project. Tick your new project, and then select "Install".
 
Share this answer
 
Comments
xhon 27-Nov-20 7:26am    
thanks for helping! I succeeded in moving unity packages in the new project but now I'm having the following error: in some of the .cshtml razor views the @Html is no more recognized...May it be related to the mentioned procedure someway?
Richard Deeming 27-Nov-20 8:06am    
That's not a problem I've seen. You could try checking the web.config file in the Views folder for the views that don't work, and compare it to the same file in the views folder for those that do work.
xhon 27-Nov-20 8:29am    
thanks for commenting, I solved the previous issue (it was not related with unity) but I'm having this new one: I uninstalled Unity package from all projects and now I reinstalled it for the web app project but UnityConfig file has not been created...
xhon 27-Nov-20 8:39am    
I tried to solve it this way: I moved the unityConfig file from one folder to the other, I added all references and now I did'n get compilation errors, but when I open the view in the browser I get the no parameterless constructor defined error. I'm pretty sure it's related to Unity configuration because I got the same error while trying to use a parametrized constructor for the controller before installing Unity

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900