-1

I'm getting the following errors when attempting to build this application. It was running fine for months and suddenly I'm getting these errors.

Severity Code Description Project File Line Suppression State Warning AD0001 Analyzer 'Microsoft.EntityFrameworkCore.RawSqlStringInjectionDiagnosticAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. PHAwebsites C:\Development\PHAwebsites\PHAwebsites\CSC 1 Active

Warning NU1701 Package 'Microsoft.AspNet.Mvc 5.2.3' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. PHAwebsites C:\Development\PHAwebsites\PHAwebsites\PHAwebsites.csproj 1

Warning NU1701 Package 'Microsoft.AspNet.Razor 3.2.3' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. PHAwebsites C:\Development\PHAwebsites\PHAwebsites\PHAwebsites.csproj 1

Warning NU1701 Package 'Microsoft.AspNet.WebPages 3.2.3' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. PHAwebsites C:\Development\PHAwebsites\PHAwebsites\PHAwebsites.csproj 1

Warning NU1701 Package 'Microsoft.Web.Infrastructure 1.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. PHAwebsites C:\Development\PHAwebsites\PHAwebsites\PHAwebsites.csproj 1

Warning NU1701 Package 'Rotativa 1.7.3' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. PHAwebsites C:\Development\PHAwebsites\PHAwebsites\PHAwebsites.csproj 1

Error rzc generate exited with code 1. PHAwebsites C:\Users\bob.nuget\packages\microsoft.aspnetcore.razor.design\2.1.2\build\netstandard2.0\Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets 121

Any ideals on what may be causing this or where I can look to resolve this.

I've searched on these errors and have found some recommendations (update NuGet packages, etc.) but none of them have worked.

Any help would be greatly appreciated. My next step is to start the project over from scratch, but I'm trying to avoid that.

Robert Hill
  • 323
  • 1
  • 8
  • 16
  • You are trying to use ASP.NET MVC 5 with ASP.NET Core. This never worked, it never will work, and the fact that your application was running for months has nothing to do with whether it builds in Core. – Ian Kemp Jan 10 '20 at 21:24

2 Answers2

0

I think you are referencing ASP.NET libraries(Microsoft.AspNet.*).

You'd like to use just Microsoft.AspNetCore.* packages for ASP.NET Core projects.

dropoutcoder
  • 2,627
  • 2
  • 14
  • 32
  • Sorry for the ignorance, but how can I check whether I'm referencing Asp.Net or AspNetCore? The NuGet packages installed shows Microsoft.AspNetCore.App and Microsoft.NetCore.App. I can send the full list of the packages as well as the version numbers if that helps. – Robert Hill Jan 10 '20 at 20:51
  • It seams C:\Development\PHAwebsites\PHAwebsites\PHAwebsites.csproj is referencing them or something else does. I am reviewing Rotitava 1.7.3 package and it seems it is referencing Microsoft.AspNet.Mvc >= 5.2.3 package. Check out Dependencies at [Rotitava 1.7.3 package](https://www.nuget.org/packages/Rotativa/1.7.3). It may or may not be the issue. – dropoutcoder Jan 10 '20 at 21:13
  • I removed Rotitava from the solution and I'm still getting the error message. – Robert Hill Jan 13 '20 at 15:24
  • @RobertHill: Take a look at https://github.com/aspnet/Razor/issues/2553 – dropoutcoder Jan 13 '20 at 16:27
  • Still having problems with this project, but I was able to resolve the warnings. Now I only have 1 error showing "rzc generate exited with code 1." I have searched for the past 2 days and found all kinds of suggested solutions, but none of them work. Very frustrating!!! – Robert Hill Jan 15 '20 at 17:51
  • Yeah. The core problem in the end might be that some errors should be threat as warnings only. Try take a look at https://stackoverflow.com/questions/54900962/ef-core-analyzer-rawsqlstringinjectiondiagnosticanalyzer-error – dropoutcoder Jan 16 '20 at 00:11
  • I checked this and the setting shows only a specific warning should be treated as an error but that was not the error I am seeing. – Robert Hill Jan 17 '20 at 16:25
0

Okay, I found a resolution to this issue. The solution is to start a new Visual Studio solution, and then add in your project details, folder-by-folder, view-by-view, model-by-model. It took a couple of hours, but now I have the project running again.

This probably isn't the answer your looking for, but it's the only thing that worked for me, and I could not waste any more time looking for an answer.

Robert Hill
  • 323
  • 1
  • 8
  • 16