toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.51k stars 260 forks source link

Visual Studio 2019 intellisense errors #328

Closed jez9999 closed 4 years ago

jez9999 commented 4 years ago

Although my class library compiles and builds, I get a lot of annoying IntelliSense errors for my .cshtml template files I'm using for RazorLight, such as:

The type or namespace name 'Rendering' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)

The type or namespace name 'ViewFeatures' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)

The type or namespace name 'IUrlHelper' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)

.. etc. How can I get rid of these errors? Is there a problem with RazorLight here?

jez9999 commented 4 years ago

I managed to fix this by using Project Sdk="Microsoft.NET.Sdk" in my .csproj file, and switching target framework from netstandard2.1 to netcoreapp3.1 - looks like you have to use .NET Core rather than .NET Standard for it to work properly.

jzabroski commented 4 years ago

@jez9999 What version of VisualStudio2019 are you using? Just wondering. Closing issue as you indicated its resolved. Happy to look at a full repro and explain whats happening/learn from the situation myself.