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,674 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Zhi Lv - MSFT 32,646 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

  2. Mohamed EL YONOUSI 0 Reputation points
    2024-06-05T20:00:36.24+00:00

    @Mufaro Tapera I think you have to stop application then try again

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.