how to fix: Asp.Net Core : There Was An Error Running The Selected Code Generator

Mufaro Tapera 0 Reputation points
2023-02-21T11:17:26.74+00:00

Hi, I have installed visual studio 2019, when I try to add controller to my ASP.Net app it gives me this error: \ There Was An Error Running The Selected Code Generator. Try rebuilding the app

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,138 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Zhi Lv - MSFT 32,006 Reputation points Microsoft Vendor
    2023-02-22T02:21:49.97+00:00

    Hi @Mufaro Tapera

    Welcome to Asp.net core Q&A forum.

    To the Generator error, first you can try rebuilding the application to make sure it has no compilation errors. You can check it in the Error List or Output console.

    Second, you can check which kind and version of code generate package you are using, and check whether it is compatible with your project?

    You can install the Microsoft.VisualStudio.Web.CodeGeneration.Design package based on your project version. For example:

    Asp.net core 3.1 application: use Microsoft.VisualStudio.Web.CodeGeneration.Design 3.1.5 version,

    Asp.net 5 application: use Microsoft.VisualStudio.Web.CodeGeneration.Design 5.0.2 version,

    Asp.net 6 application: use Microsoft.VisualStudio.Web.CodeGeneration.Design 6.0.11 version.

    After that, try to re-generate the View or Controller.

    If still showing the error, can you share the project's {your project name}.csproj file (you can double click the project, or view the project in the File Explorer, then, you can find the .csproj file)? And can you share the detailed error message?


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Dillion

    0 comments No comments