“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条回答
你好瞎i
2楼-- · 2020-01-29 07:57

try both any one will work either of them.

1.Just delete .vs folder in project solution.
2.If above fix does not work.,close your web.config file if it is opened.
查看更多
劫难
3楼-- · 2020-01-29 07:58

I was able to fix this by manually deleting the BIN and OBJ folders for my projects. Running Clean in Visual Studio did not work.

查看更多
霸刀☆藐视天下
4楼-- · 2020-01-29 07:58

I was getting this error - as my project is a git repository, I ran git clean -xfd on it, then rebuilt it and was able to add a controller when I tried again.

查看更多
forever°为你锁心
5楼-- · 2020-01-29 08:00

just use vs15. In many regards vs19 is still beta...

查看更多
叛逆
6楼-- · 2020-01-29 08:01

This issue has been resolved in Visual Studio 2019 version 16.2.4. The release notes are available here:

https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes#16.2.4

查看更多
爷、活的狠高调
7楼-- · 2020-01-29 08:03

You just need to - delete ".vs" folder from your solution directory. In summary only the deleting of the .vs folder is what has worked for me.

On reopening VS2019 16.2.3 - I can now add in Controllers and Views without seeing this error.

Found it from Microsoft Developer Community site: https://developercommunity.visualstudio.com/content/problem/626755/error-running-the-selected-code-generator-value-1.html?childToView=684261#comment-684261

code-generator-solution

查看更多
登录 后发表回答