I'm using thbe Microsoft Ribbon for WPF (System.Windows.Controls.Ribbon) and VS2015. Since I removed unnecessary depencies from my project (like Dynamic Data Display etc, things not related to the ribbon) it does not render correctly in the Designer anymore. All RibbonButtons get rendered as usual buttons and so on.
I used the Clean Solution option and also rebuild multiple times, without sucess. While execution everything is fine, just the designer can't handle the ribbon anymore. What could have caused this strange behaviour?
This is how my ribbon looks now in the designer:
And this is how it's supposed to look and looked before:
Update: it clearly seems to be a visual studio bug, as I opened the project on another machine with the same VS version and there everything is fine.
deleting %LOCALAPPDATA%\Microsoft\VisualStudio\14.0\Designer\ShadowCache wasn't working but this:
close solution (at best every instance of VS, you never know)
delete bin\ and obj\ in solution folder ("Clean Solution" isn't enough nowadays. Why should it? It isn't anything anyone would ever do if VS is doing strange things. Maybe I should fall back to kill -9 devenv.exe && git clean -fX as default m( )
Reopen solution and hope for the best.
This drove me nuts. The only real google hits for this problem was this SO question, another one without any answer, 500+ pseudomirrors of SO and thousands of false positives... sorry for the rant.
The problem was resolved by clearing the Visual Studio Designer Cache.
This is done by deleting the subfolders in %LOCALAPPDATA%\Microsoft\VisualStudio\14.0\Designer\ShadowCache
Related
Yesterday I edited a form in Visual Studio's form designer. When I returned to it today, the designer shows nothing. I can open the properties window, select all the different constituent components and edit their properties, but they do not show up. The application builds fine and the form can be run as usual.
I've tried a couple of different solutions, such as checking the .csproj file has the form.Designer.cs included, but nothing has worked.
Strangely, I did see this problem earlier in the week, but it fixed itself when I unlocked my computer after returning from a coffee break.
Any suggestions?
I face a similar problem in Visual Studio 2019.
To help others who may have this issue.
The problem is due to the class declaration in the Form1.cs file.
Please ensure public partial class Form1: Form class is the first-class declared in the file. No other class declaration should be on top of this.
As described in this answer: https://stackoverflow.com/a/40243490/8887398
Thanks,
Sankar
I had similar issues in VS2019. I resolved it by using:
Window > Reset Window Layout.
Then double clicked on the Form in the Solution Explorer.
Prior to this, double clicking the form was having no effect.
Weird, after trying for an hour I ended up solving the issue 30 seconds after posting this!
I edited the size property of an item on the form using the properties tab, saved the form, and then reverted the form.cs, form.designer.cs, and form.resx files to the latest source control version.
At this point the form jollily re-appeared.
Edit: FWIW, this didn't work with another form which was exhibiting the same problem.
Edit 2: That other form has now fixed itself after coming back from lunch and unlocking my PC... Might be something to do with how that affects the display - everything shifts over to my right hand monitor when I do that.
Edit 3: OK, now it seems that modifying my display DPI fixes it. On Windows 10 go to System Settings -> Display, and then move the "Change the size of text: 100%" option to say 200%. Once this changes on screen, move it back to 100%.
This seems quite foolproof, although you sometimes have to jimmy it around a lot before it finally works. I know it has worked when I get both a vertical and horizontal scrollbar; the form is then further down the page.
Just go to Form1.cs (Form1 is the name of your form), if you are able to see your source code then press Shift + F7. The form will show up.
I also had a similar issue in VS2019.
My form [Design] was listed in the solution explorer but the code was not listed as a sub-item of that form.
I could access the code by right-clicking on the form in the solution explorer and choosing view code.
What seemed to solve the problem was to close down VS2019 and simply re-open it up.
A Message appeared (with Errors and Warnings) for me which said that the first mentioned class in a cs code file must be the form class. I shifted my form class to the top of the files and everything was fine.
There are actually a few reasons that one might encounter this issue.
At times, it can be due a problem within the VS IDE and the way it incorrectly manages file types and subtypes. It normally does a great job with this "automagically", but it can also make painful and unexpected mistakes.
If you right-mouse-click (RMC) your Project, and unload it (not your solution) you will be able to RMC it again and choose "Edit Project File". Once there, search for your Form name. In my case, I will search for Form1.cs, note the incorrect icon I saw in the Solution Explorer View, and the code describing my form, within the project file:
<...>
<Compile Include="Form1.cs"/>
<...>
Change this declarative statement to the following, adding the "Form" subtype:
<...>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<...>
Save your project file, then RMC on your project name in the Solution Explorer, choose "Reload Project", and you will see the correct icon as expected, and once again be able to use the form in Design mode:
*Note: This issue shouldn't occur with default forms (named Form1, Form2, etc) and even in my case, it happened with a form I named other than the default form name. I used that name in this example, purely for illustrative purposes.
Hopefully, this helps someone.
Wishing you all the best!
I hadn't changed anything that would have broken my form, yet it still wouldn't load when I tried view designer. Restarted VS2019 and it worked after that. Give that a go before you try anything else!
I had the same problem.
My solution was to remove and add again the System.Windows.Forms reference.
Go to Tools > Options > Environment > Preview Features and select the Use the preview Windows Forms designer ...
Then restart
I've got a project that contains usercontrols. For some reason, the design view for the window which uses the said controls has stopped functioning and insists on "Invalid Markup" - the error given is that some members of the usercontrols are not recognized or not accessible. The project however compiles and executes just fine. Loading it up in VS2010, the editor works fine, no errors whatsoever - the same even in Expression Blend.
So far I have tried the typical clean, rebuild, manually deleting stuff from obj, updating the .xaml and rebuilding, tried starting VS2012 with /resetuserdata and /resetsettings - the problem persists. I even rolled back to a much older revision of my project, back when the designer was working just fine, no dice - same error. I also tried launching VS2012 as a new windows user to avoid any stored appdata that might be lingering, again a no go.
Is there some other sort of cache or something that I could manually delete?
There's also an issue with the ShadowCache (used for rendering designer) getting out of sync with your XAML in VS2012. I just found this out, as I was having a horrible time with the following error with derived user controls:
The local property XXXX can only be applied to types that are derived from YYYYY.
The shadow cache is located in your user profile directory:
app data\Local\Microsoft\VisualStudio\11.0\Designer\ShadowCache
You can delete everything in there and restart VS2012. After that, things worked much better (for at least a while!)
Delete everything in ShadowCache
C:\Users\username\AppData\Local\Microsoft\VisualStudio\11.0\Designer\ShadowCache\
Copy-pasteable paths
Just copy/paste one of these paths into Windows Explorer. %LOCALAPPDATA% is a Windows Environment Variable it will be replaced with the corresponding value when entered into Explorer (also works in Command Prompt)
VS2012
%LOCALAPPDATA%\Microsoft\VisualStudio\11.0\Designer\ShadowCache\
VS2013
%LOCALAPPDATA%\Microsoft\VisualStudio\12.0\Designer\ShadowCache\
VS2015
%LOCALAPPDATA%\Microsoft\VisualStudio\14.0\Designer\ShadowCache\
ASP.NET
If you develop ASP.NET also delete
%LOCALAPPDATA%\Microsoft\WebsiteCache
%LOCALAPPDATA%\Temp\VWDWebCache
I'm not sure this will fix all cases but this is what worked for me (all the time now).
I have VS2012, using the Blend designer in the IDE, building an x64 application, when I would define a new ICommand and add the Command attribute, I would get the designer isn't supported in x64 error (I forget the exact warning). If I switch to x86, I'd get invalid XAML markup errors complaining the the ICommand wasn't recognized or was not accessible, no matter how many times I rebuilt in x64. If I switch to x86, build, then switch back to x64, voila, not problems with the designer.
Now I recall similar issues with VS2008 and Blend version 3 and 4. From what I've read in other posts, using Any CPU might also resolve the issue.
May be you have added user controls which are not supported or you might have added some wrong parent-child relationship in your user controls . Try removing the suspected User Controls and rebuilding the project . It must fix the issue .
Cheers
You need to re:encode your xaml, open bugged files in ide -> save as -> save encoded (choose UTF8)
I've the same problem while using controls with a custom (no param) Constructor.
Check if the Custom/User Control constructor doesn't require any data that the WPF designer doesn't have. A quick wait to check that is surrounding the whole thing with a try catch, cleaning, rebuilding and then check to see if the problem is solver.
If it is not, try commenting everything except the default WPF Init cod, clean, rebuild and test it out.
In Visual Studio 2013 this is a workaround I using for my Windows Phone Project, http://danielhindrikes.se/visual-studio/workaround-for-invalid-markup-problems-when-developing-for-windows-phone/. I guess it is the same designer that is used when you writing XAML for WPF.
Have tried to delete Shadow Cache but itjust work first time I start Visual Studio, above workaround is the only thing that helped me.
A little late, but something else to consider: If your no-parameter constructor is doing some other work, like getting data that doesn't exist because you are in the designer, add this at the start of your constructor:
if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) return;
// Do work.
This is necessary because the designer does execute your no-parameter constructor which may fail in design mode an give you the invalid markup.
And, regardless of what others are saying, this is not a VS or WPF XAML Parser bug. I ran into this issue today using VS 2015, .Net 4.5.2.
I just had the same problem (program compiling and running fine, XAML designer reporting invalid markup), the issue was that I had accidentally changed the assembly name of one of the projects in my solution, I changed it back and my XAML designer sprang back to life, so check the Properties page of each project in your solution, and ensure the Assembly Name is as you expect it to be.
I think there is no problem in your project, but it is problem in VS 2012. Try to install the latest update for VS 2012 (Update 2) and also check this answer.
Regards,
I have the same Problem with VS 2015 and 2017 but only if I compile for x64 only.
Here it helps if I change compile target (Project properties - Build, its called Plattformziel in german) temporarily to x86, compile to project and switch back to x64.
Maybe this is a "solution" for anybody else.
I'm working on an existing WinForms application and I am having some weird issues with Infragistics controls in a WinForms app.
When I open a form or usercontrol in the project that has Infragistics controls on it, it looks like
this http://sdrv.ms/S7gvmS
I cannot access any of the controls in the design surface. Clicking does nothing. And, all of the controls appear in the lower area.
So I created a new test solution and dropped some Infragisstics controls on and got this http://sdrv.ms/SRdo2y
Anyone know what's going on?
When I've run in to similar issues before it's tended to be a license or version problem, the Infragistics libraries contain code stopping them working at design-time if a valid license isn't installed. To resolve this, I'd first recommend deleting all of the *.licx files in your solution. These can be easily corrupted especially if you're using source control and should be regenerated correctly when you go in at design time. If that fails, then I'd try uninstalling and reinstalling Infragistics ensuring the version installed matches those of your projects' reference.
P.S. Realise this is far too late to help the original poster but hopefully will help people coming across similar issues in the future.
This happens when Visual Studio cannot find the Design assembly. The components refer to a designer and if Visual Studio cannot find the designer, it makes the assumption that the object is a component instead of a control and places it in the system tray.
Typically, this indicates that something when wrong with your installation of the components, so the usual solution is to re-install.
I'm a big fan of the rather obscure "Document Outline" window in VS 2008 (it's buried in the View -> Other Windows menu).
It's the only way I know to get a view of the containment heirarchy for a complicated WinForm that has a lot of nested controls.
Some months ago, this just stopped working for the most complicated form in my WinForms project. Now it just displays "There are no items to show for the selected document", no matter what I select in the designer.
No clue as to what broke it - the form contains a mix of common MS controls and some third party controls (mainly DevExpress). Several SplitContainers, but Document Outline originally had no problem with these.
Anybody else seen this, and any suggestions on how to fix it?
After some poking around, I solved the problem myself.
I just started deleting controls from the form, to see what would happen.
Turns out the 3rd party grid I'm using caused the problem - when I reconfigured it, the problem went away. (Looks like a bug in the control, which I've reported to the vendor).
Interesting...misbehaving controls can break the VS IDE, not just your apps.
Working on windows forms in Visual Studio 2008 with C#
So I had a windows Form Control that wasn't behaving the way I wanted. So I overloaded the Size property.
Bad idea. Everything broke. Horribly. I could not add this control to a form anymore. This was slightly problematic.
So I removed the offending code, and recompiled. Problem solved... right?
Not so much. I can't add this form to my code STILL. And it was working before. I scour the code for any changes I could have made, recompile again, and nothing changes.
So I conclude, that my code is correct, my DLL is pristine, and it's just not reloading the toolbox.
Close visual studio, open it back up, and everything works just fine. (well, works like it did before I broke everything)
Is there a way to do this WITHOUT closing out 2008? Because it's really quite annoying.
Try closing the solution & opening it again.
Or closing the toolbox tab & again enabling it via View-> Toolbox
Try Cleaning and recompiling the whole solution. Another trick is to delete all binary output (this includes the obj-folder) of each project.