issue with trying to use Microsoft.Extensions.DependencyInjection with Visual Studio 2013
so im trying to create a small intranet website using Visual Studio 2013. i wanted to learn and incorporate MVC razor in the process. to add logins with user roles i searched and found multiple examples to do simple role authorization, such as: https://docs.microsoft.com/en-us/aspnet/core/security/authorization/razor-pages-authorization?view=aspnetcore-2.2 https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles?view=aspnetcore-2.2 https://wakeupandcode.com/authentication-authorization-in-asp-net-core-razor-pages/
all these examples say to add this snip of code for initialization:
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddAuthorization(options => .....
intellisense didnt like IServiceCollection. a quick web search said it was part of the Microsoft.Extensions.DependencyInjection package. easy enough, i went through nuget to grab it but started getting install errors:
Could not install package 'Microsoft.Extensions.DependencyInjection 2.2.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework.
checking, the target framework is indeed 4.5. after some digging i saw that it required also Microsoft.Extensions.DependencyInjection.Abstractions, and .netStandard 2.0. installed .netstandard, but couldnt install the latest Abstractions as it had the same install issue.
one source suggested i download the Microsoft.Extensions.DependencyInjection and Abstraction version 1.1.1. tried it, it installed ok but the methods AddMvc() and AddAuthorization() still werent visible to intelisense. so im thinking they are part of the 2.0 version.
another source suggested upgrading the nuget manager to the latest version, but the version i have is the latest version for visual studio 2013. the next updated version is for VS2015 and higher.
so im wondering, does this mean i cant install DependencyInjection with Visual Studio 2013. none of the examples ive seen said that these features are only exclusive to newer VS products but im wondering if they are.
0 comments:
Post a Comment