Reputation: 127
First off, I wish I had more information to give you but I am kinda puzzled with this error from Microsoft Visual Studio 2015:
An error was encountered during code generation. The changes you have made in the designer have not been committed to the source code. It is recommended that you close and re-open the source file. The error message follows: Value does not fall within expected range.
A bit of additional information I hope will be useful... This has been my first time encountering this nagging and persistent error. Right after my day job, I sat right down on my computer and started working happily away on my lil programming project. Everything was good, VS2015 Community started up like usual, but AS SOON AS I PLACED ONE BUTTON (literally, one button... dragged and dropped... didn't change anything else...) from my toolbox onto my winform, this agitating error pops up screaming nonsense. I worked for hours on my little project yesterday, debugged and tested everything before I went to bed and it all worked perfectly fine. I was happy.
I did some online research, and tried everything from repairs/reinstall to VS2015 as well as other things, like making sure all my columns in my SQLSERVER Express DB are set Visible = True. They were. I tried closing and reopening my project, VS 2015 and even restarting my desktop. This awful error is persistently following me for dragging and dropping a button on my winform, and I hope I don't lose my project. The backup save I tried to load is doing the same thing as well. I also read this was supposed to be an issue fixed with SP1 for VS? Just in case, I made double sure I'm currently up to date with fixes and downloads from Microsoft for VS.
Has anyone run into this error?! If so, please advise on how to fix and save my behavioral statistics calculator!! Thanks Overflowers!
Upvotes: 9
Views: 19536
Reputation: 21
If there is anybody new to C# also, like me, I encountered it months ago, and the problem "solved itself". At that time I was still like early new to C#, with a bit of Pyhton knowledge. And today I encountered this error again, also on a personal project I'm working on...
And I accidently came across the solution, I was struggling heavily to fix it, becasue I made BIG changes to my form, and stressed because of all the changes I had to redo after restarting VS..
Well, you have the "mainpage(or whatever you named your form)".cs(design) tab and then the script/C# file for it, namely "mainpage.designer.cs" which has a lot of "this.whatever = new System...." in it. Your error lays there, litterally change anything, even adding a letter anywehere randomly, and try to save, then just undo the changed, and save again.
It worked for me, though.
If I ever come across the same error in the future, I will test this method again, and reply to this message as an update.
And great day furtheron programming!!
Upvotes: 2
Reputation: 1
open your source code page cut every thing then start the project you will receive an error edit then past your code agine
and start your project it worked for me
Upvotes: 0
Reputation: 15772
I got this message after creating a TableLayoutPanel and moving some controls into it. At that point, I couldn't save the source file, the Designer file, our either from the [Design] view.
I was able to undo the last changes by selecting everything in the Designer.vb file, cutting it to the clipboard, and saving. No error message. Then I pasted everything back, saved again, and there was no error message. I checked the [Design] and the TableLayoutPanel was gone, but my controls were where they were prior to adding them to it.
After that I repeated the same steps to add the TableLayoutPanel and put the controls in it and I got no error message. It was relatively inexpensive in terms of wasted time to deal with this message. I'm not sure what would have happened if I had closed the solution according to the messages suggestion but I didn't need to find out.
Upvotes: 2
Reputation: 31
It is a problem in VS and Microsoft provided a hotfix for the issue.
Upvotes: 3
Reputation: 1
I received the same error and all I did was open up the code page and delete everything on the page. I was then able to save all. Once I did that I closed and reopened Visual Studio and then reopened my project.
I hope this helps.
Upvotes: 0
Reputation: 149
Follow this steps:
1.Create a new project.
2.Copy your code and all controller to new project (step 1).
3.Exit from old project(Will not be saved) without saving.
4.Re open old project(step 3).
5.copy your all source and all controller(from step 2) to your project.
6.Save your Project.
Upvotes: 0
Reputation: 1433
This may not be the answer, but may lead to a solution to you or somebody else.
I came to this question because I've got the same message
"An error was encountered during code generation. The changes you have made in the designer have not been committed to the source code..."
In my case, I created an UserControl with a Boolean property called Vertical. I added this UserControl to a Form. Everything worked, I could see the programmed behavior on the Form designer flipping Vertical property from True
to False
and viceversa.
Days later, I decided it would make more sense to rename the Vertical property to Show_Vertically. And few minutes later the message was there.
It turns out that whenever I added the UserControl to a Form, the designer automatically generates code inside its InitializeComponent()
routine with the initial UserControl1.Vertical = True
The solution is either to change the statement inside the hidden InitializeComponent()
routine or to remove and add the UserControl to the Form again.
From your comments above, I assume your error was in your SearchInventButton
. I would get inside the InitilizeComponent()
routine and look for any property assigned to SearchInventButton. If the button is not the problem, it may be any non-standard control that got updated like I did with mine. (You were talking about some SQL columns, did you removed some columns or changed their name? It may be that the designer assigned some format to those ones and now the designer can't find the column) But without further details, these are my 2 cents to the community.
Upvotes: 0