I recently got a new computer and a copy of Visual Studios 2015. I opened some older projects (C#, winform, VS2010) and can edit the code just fine. However any changes to the UI in the designer, causes the entire UI to or not show part of the screen or glitch out.
Has any one ever experienced these issues? If so, how do I fix i?
Edit:
I discovered the issue has to do with the AutoScaleMode attribute of my project's form.
I wound up setting the form's autoscalemode to none. Doing that seemed to take care of my issues. I had to reorganize my UI but that was worth having the ability to use the designer again.
Related
I am working in C# with Visual Studio 2017. I had previously made some changes to my form, and today when I run the code, the changes don't show up. It appears to be running an older version. Note that when I originally made the changes, it ran fine with the dropdown working.
Here is the edited version:
And here is what it looks like when it runs:
I have restarted VS and restarted my computer, both to no avail. I have searched extensively and can't find the answer.
Is there some setting I accidentally hit? Please tell me it's something obvious and not a weird glitch in the VS matrix.
Thanks!
You were using an old DLL/EXE.
This can happen in a few scenarios, typically if you store your binaries (DLLs built with your project) in source control.
You'd be surprised how many developers get caught out with this. It's often due to being pedantic about EVERYTHING being in source control - including the items you build!
Best thing to do is delete the bin and obj folders from source control. If it's a new project it's often easier to start fresh with a new source control project.
GAC'ing your DLLs is another common cause of this situation.
I am working with winforms, .net 3.5 Visual Studio 2008.
The code is compiling, the winforms designer suddenly stops showing forms,
with different messages, for example
'Resco.Drawing.GradientColor' cannot be converted to type 'Resco.Drawing.GradientColor'
'Method not found: 'Void Resco.UIElements.UIControl.set_TextAlignment(Resco.Drawing.Alignment)'
The variable 'ucMessageBox1' is either undeclared or was never assigned.
Again, the code compiles and runs, and no changes habe been made to the form or usercontrol, that cannot be displayed, since it xold be displayed
Sometimes it helps to clean and rebuild, sometimes it help do delete the .suo file.
Sometimes it helps to shutdown and restart Visual Studio.
Sometimes I do not find a solution but somewhen it works again.
I have two solutions with identical Source code for two Platforms, windows and windows embedded, sometime the same control is shown without problems in one solution but not in the other.
I have this same issue with VS using DevExpress. I find if I close the designer mode and re-open it, it will work. At worse, I restart Visual Studio and appears to fix the problem.
That often happens when I work with Telerik, to resolve the issue I often have to do:
Repair the software library I installed for it.
Remove the reference, then Add the reference to the .dll again.
Ignore the designer mode and simply work in code behind.
Sadly, the last result is where I often find myself. Usually I'll simply code straight in code behind, as all the functionality exist but I don't have to deal with the issue every time I close / reopen Visual Studio. Since all the functionality exist in code behind, just unable to access the designer.
Honestly I'm not sure why it happens, but it happens often enough to where I avoid Telerik.
In my application, I use the ScintillaNET DLL and have created a class called BufferedScintilla where I am inheriting the control and double buffering it. Nothing unusual, just the normal C# inheritance... Than, I modified my form's Designer.cs file and switched from using ScintillaNET.Scintilla() to BufferedScintilla().
The app loads and works fine as expected BUT Visual Studio 2013 designer fails to load, telling me that "Unable to cast object of type BufferedScintilla to type ScintillaNET.Scintilla.
I tried everything, cleaned the solution and rebuild, rebuild only, debug, closing and restarting Visual Studio and even restarting the PC, but nothing helps at all... Visual Studio Designer refuses to let me design my form.
Again, the app runs FINE, and I am sure that the control on the form is the new BufferedScintilla, not ScintillaNET.Scintilla, because I can see the effects (it is double buffered, the custom graphics I am drawing over it do not flicker anymore), so I am 100% sure the app runs WITH the inherited component.
I am sure this is some kind of Visual Studio little flaw, so I am looking for a solution to have it let me design my app again.
EDIT: To clarify, the same thing happens in Visual Studio 2013 Update 1 and Visual Studio 2010 too. I checked the assembly, it is built as Any CPU, so there should be no problem with the Visual Studio designer...
EDIT: As it seems impossible to fix this (some kind of a bug), I am looking forwar to a way of replacing lines in the Designer.cs file automatically before building the project, and then after the project was built (or not). Is there any Visual Studio tool which will replace some text in the class automatically after pressing the Build button before the project is built, and after it has been built? I want to replace the constructor and declaration, so that at design time it is ScintillaNET.Scintilla, and at run time it is BufferedScintilla. Thanks!
Thanks in advance!
Vali
I've run into a problem very similar to this, In my case the designer still uses the constructors and the loaded events that are setup for the controls and forms. In my case, i was using a variable that was never set during design time, so to go around this you would have to modify you're code to do something like this...
if(this.DesignMode)
{
//DoSomething();
}
else
{
//DoSomethingElse();
}
I'm getting the following error
Could not find type 'My.Special.UserControl'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.
But what doesn't make any sense is that My.Special.UserControl is in the same assembly as the form. What's more, if I view code on the Designer.cs file, There are references to My.Special.UserControl that seem to be fine. The assembly builds fine, and runs fine as well. It's the just the designer that's having issues.
As such we have to do all our design work by making adjustments to the Designer.cs file by hand. How can I make the designer work again?
The following procedure has worked for me:
Delete the /bin and /obj folders in your source code directory.
Restart VS (be sure the offending Form Designer is closed)
Compile
Open the Form in Designer again. The problem should be resolved.
I'm sure deleting both /bin and /obj are not necessary, but I haven't been able to reproduce the error and come to a more specific solution. (My projects are typically small enough that re-compiling the whole thing is no big deal.)
Usually, this error seems to occur after refactoring / renaming objects of the offending class. So my guess is that there is a VS bug that doesn't recompile the appropriate object file after a User Control or Custom Control is refactored.
Change the project type temporarily to x86, compile and open the Designer. Visual Studio is a 32 bit application.
There is propably an exception happening in the Load or Initialize Part of your Form / UserControl. Can you try to comment out any code there and retry opening in designer?
You can use another instance of Visual Studio to attach a debugger to your Visual Studio instance not letting you open the Form. Once an exception occurs you will be able to pinpoint the location where something goes wrong.
I had similar problem when shifted from VS 2017 community edition to professional.
Close VS
Go to Project folder
Delete .vs folder. Back up if you need.
Start VS
This should solve the problem
I have experienced the exact same problem. I am fairly certain that it is connected to the platform target x64. Here is a related post mentioning it as a bug in Visual Studio:
https://stackoverflow.com/a/11582828/7665665
How I deal with it: Although my solution is actually only x64, I have created another platform target x86 for the projects just to be able to use the designer. Now I switch the target to x86 in order to see my controls in VS Designer. For everything else, I switch back to x64.
I had the same problem with a user control which was derived from the standard .NET control within my form.cs. Nothing of the above worked for me (my solution is compiled as x64 because of other unmanaged components which only support x64).
I finally ended up with creating a separate project "Utils" and moving the offending derived controls to this project. This worked like a charm !
In my case I just unload project and reload again
Switching the project target to x86 was the only possible solution for me
This happened to me today. Cleaning, Rebuilding, restarting Vs and even rebooting did not help. Everything ran as expected, the only thing that would not work was the designer in VS.
In my case, since nothing lese worked, I went to designer file, removed the faulty control and then added a new one. Renamed, re-assigned event listeners and it worked.
Designer now works, but if this must be some kind of VS bug, I don't know.
This is not the answer I'd like to read when coming to SO, but I'll post it in case it helps anyone later.
For me, I deleted the .resx file for the form, and it built and showed up in the designer, no problem. Go figure....
I had a similar experience when I sub-classed DataGridView. The following procedure has worked for me:
Close the Form Designer tab
Close VS (2015)
Delete the /bin and /obj folders of the project
Restart VS
Rebuild the solution
I don't know which steps could be skipped as I have not taken the time to refine the process.
On my project, it only worked if I made the custom user control in a separate project in the solution:
Add new project "Class Library (.NET Framework)"
Add references to System.Windows.Forms & System.Drawing
Add the source of the new user control in the new project
Build the solution
Open the designer
Drag the new user control in the form
In my case the designer automatically added a reference to the new project when I dragged the custom user control in my form.
Hope this help others who stumble upon this question.
When I open form designer, it freezes - shows a blank page or what was shown before. This is how it looks:
I have FormMain.cs [Design] opened, but it shows contents of the tab that was there before (also it causes another issue in solution explorer, but that gets solved when I click anywhere in the solution explorer). I tried deleting the .suo file, but it didn't solve the issue.
Also for some reason, I can right-click and lock controls, then unlock and it solves the issue temporarily, when I open another tab and go back to the designer, it's frozen again. It happens only for FormMain.cs, the other 2 forms are okay, so I thought it might be something in the designer code - http://pastebin.com/AxTdEbg3 - but even if I delete all the controls from FormMain.Designer.cs, it still freezes.
I have Hotfix (KB2635973) and Service Pack 1 (KB983509) for Visual C#, .NET Framework 4 SP1 (but the project uses 3.0). Thanks for all answers, if you need some more information (like the whole project folder), then I'll upload it.