“There was an error running the selected code gene

2020-01-29 07:57发布

I am working on an ASP.NET MVC project and so far I had no problems with scaffolding any type of items until now.

Every time I want to create a new controller or view, I get the following error message:

There was an error running the selected code generator: 'The value -1 is outside the acceptable range of [0,2147483647]. Parameter name :value'

This issue only arises in the project that I'm currently working on as I tried creating a new controller in another project and it worked flawlessly.

I already tried the solution to delete the ComponentModelCache folder and rebuilding the project but the problem still persists.
My Visual Studio 2019 is also up to date.

EDIT: Pulling the project from git source control on another PC and restoring the packages fixed the issue for me. You probably don't have to do it from another computer, just try deleting the project and restoring it from remote.

EDIT 2: Creating a second view and the same problem is back again...

13条回答
我想做一个坏孩纸
2楼-- · 2020-01-29 08:03

I tried it all and finally found a solution that worked, this issue only happens when the web.config file is open in the editor. Hope this help.

Credits : Vijay Ramakrishnan [MSFT]
https://developercommunity.visualstudio.com/content/problem/626755/error-running-the-selected-code-generator-value-1.html

查看更多
虎瘦雄心在
3楼-- · 2020-01-29 08:05

Go Back to VS 2017 and it will work just fine

查看更多
Luminary・发光体
4楼-- · 2020-01-29 08:10

i fix it, deleting the .vs folder, re opening the project, and clenning the solution

查看更多
\"骚年 ilove
5楼-- · 2020-01-29 08:15

I was able to fix this by replacing the web project with a new one.

-I renamed the project like project_old folder and removed it from solution. -Added a new project to the solution by right click and add project -Created the old controllers and everything with copying from old project files -Updated nuget packages and deleted old project files

Clean Solution -> Rebuild Solution and voilla

查看更多
SAY GOODBYE
6楼-- · 2020-01-29 08:18

I fixed this by unloading and reloading the project

查看更多
唯我独甜
7楼-- · 2020-01-29 08:21

One of the possibility is if your web.config file is open then this error might appear. Try closing the web.config file and then add a View.

You can also reach out to this website for more reference: Error Running the Selected Code Generate Value

Hope this helps.

查看更多
登录 后发表回答