the value -1 is outside the acceptable range of [0,2147483647]. Parameter name: value

被刻印的时光 ゝ 提交于 2019-11-29 14:15:33

The issue is now fixed with the latest release of Visual Studio 2019: version 16.2.5: https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes#16.2.5

The issue would only to happen when:

  • you have the web.config file for your project open in Visual Studio.

So the workaround for was:

  • if you have the error, make sure you close the web.config file and you will be able to scaffold controllers.

I ran into the same problem tomorrow, tried many manipulations found on different subjects, nothing worked. Finally, someone gave me a "solution" that let me continue my project, which simply is copy/paste any view...! Of course, you'll then have to hand code everything, but at least it'll let you add new views/controllers to your project. Hope this helps!

I just found how to solve it for me after attempting many things.

My solution was to:

  • first navigate to the project folder with the solution and delete the packages folder.
    • Also delete .vs folder in the root of your solution
  • Then in your project folder delete the bin and obj folders.
  • Close your Visual Studio instance.
  • Next step is to navigate to your local user folder:

    Ex: C:\Users\[YourUserName]\AppData\Local\Microsoft\VisualStudio

You will see folders 16.0_ or 16.0_e9eb2d6b (Depending on your VS version). Navigate to the second folder 16.0_e9eb2d6b and delete the ComponentModelCache and Designer folders.

  • Close web.config file in the editor

  • Last step is to open your solution project in VisualStudio and click on Rebuild Solution from the Build tab.

Now try to create a View in your MVC project.

I hope this helps!

VS team is still working on this issue:

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

However, I have used VS 2017 to add the Control and I re-opened the solution with 2019 version and it seems to work

This is what worked for me. Your mileage may vary.

1) Exit the solution from the IDE.
2) Delete the .vs folder (this may be hidden on your system)
3) Delete the packages folder under your solution.
4) Open the solution and perform Clean Solution from the IDE menu.
5) Restore the Nuget packages.
6) Try adding the new controller now.

Before Creating a View or Controller Make sure that your Web.config file is not open...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!