I am struggling to find out whats wrong with MVC 5 (Visual Studio 2015) Ninject dependency injection. In MVC 4 (Visual Studio 2013), it was quite straight forward to add Ninject with Nuget Package Manager(UI) but don't seems like the case with MVC 5 (VS 2015).
After some unsuccessful attempts, I rather used Package Manager Console and got Nuget and Nuget.Web.Common both packages installed.To my surprise, I can't find my NinjectWebCommon.cs file in App_Start folder now.
I am wondering if MVC 5 has changed the concept of dependency injection or I am doing something wrong here?
You need to install the Ninject.MVC5 package. This will add (amongst other things) the NinjectWebCommon.cs file in App_Start.
Related
I have upgraded my asp.net core,using project.json and targeting .net framework 4.6.1 on visual studio 2015 to visual studio 2017.
I have multiple projects in the solution where the main application is referencing them by project reference(all of them target net461).
When running the application I get
One or more compilation references are missing. Possible causes
include a missing 'preserveCompilationContext' property under
'buildOptions' in the application's project.json.
screenshot:
I have tried adding the true
to all of the reference projects without luck.
Can anyone help? Thank you.
Look in your Login.cshtml file and ensure you give the fully qualified name to the model to find your LoginViewModel and inject your SignInManager. Something like this:
#model company.Web.Models.AccountViewModels.LoginViewModel
#inject Microsoft.AspNetCore.Identity.SignInManager SignInManager
That should allow the view to serve the page correctly.
I've got an old project from a friend that he wants me to do redo. How ever that project is written in ASP.net mvc2. So When I try to open it in visual studio 2013 I can errors. Saying the file is incompatible. How would I go ahead and fix this?
I would highly recommend you to create a new empty MVC 5 project, and move all your files there from old MVC 2 project. If you just try to update DLLs its very hard be sure if you updated all DLLs, proj file, nugets, or at least little bit more work by copying files is well worth it. Problem is that VS2013 is not compatible with old version of MVC framework.
But, if you really want to open MVC 2 solution in VS2013, you can try following some steps described here: How do I open an old MVC project in Visual Studio 2012 or Visual Studio 2013? (contains a project Guid that needs to be changed inside .proj file)
I have attempted to create an MVC 5 project by creating an MVC 4 project in Visual Studio 2012 and installing MVC 5 through Nuget.
I can build this fine.
I attempt to add a reference to another DLL, Sitecore.Mvc.DLL, which I can see was built against MVC 5.1.0. The DLL reference is added fine, and there seems to be no .NET framework conflict (which is where I've seen this issue in the past).
I'm trying to add a using statement to my code:-
using Sitecore.Mvc.Presentation;
IntelliSense picks this up fine....even allowing me to auto-complete 'Presentation'.
However when I build I get the following error:-
The type or namespace name 'Sitecore' could not be found (are you missing a using directive or an assembly reference?)
What could be the issue here?
I'm using:-
Visual Studio 2012 - Update 4
MVC 4 Web Application (initially)
MVC 5.1.0 Nuget Package
Sitecore 7.2 - Update 2 (where Sitecore.Mvc.DLL comes from)
.NET 4.5.2 installed on my machine.
Turns out I'm using a different version of Sitecore.Mvc.DLL, which IS targeted to .NET 4.5.1. Seems like the mscorelib reference in Reflector doesn't quite tell all the details.
Now I need to target my Web App to .NET 4.5.1, which means I need to follow the steps here to be able to select it.
http://blogs.msdn.com/b/dotnet/archive/2013/08/08/building-apps-with-the-net-framework-4-5-1-preview-in-visual-studio-2012.aspx
Thanks, and sorry to #Khanh TO, and everyone else for helping out.
I recently made some unit tests for my Asp.NET MVC application, or I tried to, it keep telling me "The type 'System.Web.Mvc.Controller' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Mvc, Version=5.1.0.0, Culture=neutral.' Then I tried to add a reference to the above mentioned, but was only able to choose version 4.0.0.0 and now it tells me that my project already uses version 5.1.0.0, which is a higher version. What to do?
Thanks a bunch!
MVC 5 comes in from a NuGet package. Just as it did with the main MVC web project in your solution. Install MVC via NuGet into your Test project, and you should be good to go.
An educated guess, but you might have obtained the newer version via a nuget package(some of the newer MVC project templates do this), and thus it is not installed in GAC. Use the nuget package manager for the MVC project to determine if this is the case, and if so then mystery solved.
In the test project you can add the same package, or use the addreference->Browse to browse into the nuget dependencies and poke around under the MVC project till you find the DLL(it will be in the file system somewhere under SolutionName/MvcProjectName/packages).
I am using WSPBuilder on Visual Studio 2010 to create a feature with a feature receiver assembly for SharePoint 2010. When I try to build the WSP using WSP Builder I get this message in the output window:
The assembly MyAssembly.dll is unmanaged. The assembly will be excluded from the WSP package!
The defined Project Assembly seems not to be a valid assembly!
Solution compatibility: SharePoint 2010
The resulting WSP that gets built does not contain my DLL.
My DLL is strongly named, and I cant think of any other obvious reasons why this is happening.
Any idea why WSPBuilder is not able to package my assembly in the WSP?
Ahh... Found the answer. My code was getting compiled against .Net Framework 4.0. Changed it to .Net Framework 3.5 and Voila! WSP gets built without any problems...