I'm working at huge project, which was converted from VS 2008 to VS 2012. Everything worked fine before, but now I have a problem in VS 2012.
Opening a form in VS Designer causes changes are made in that form. If I save that auto made changes, I can't open it anymore, cuz there are errors in it. Can I somehow force the designer not to make the auto changes?
I believe you can set the [filename].Designer.[extension] file as Read-Only, and while the designer will still make changes (shown by the asterisk that appears in the tab), they won't be automatically saved. And you'll have to answer "No" when asked to save changes. It's not the perfect way to preserve the layout code while developing the class behaviour, but it's doable.
Related
I know there are a lot of problems like that and you all might think this is a duplicate but NO... this problem is different.
When I add a custom user control to a project and rebuild it, the control is added to the toolbox. If I try to add another one it does not show up in the toolbox. If I close visual studio and reopen it the first control also was removed from the toolbox and will never appear again. From now on the project is broken and no control added, remove + readded will ever show up in the toolbox. So I create a new project and it starts from the beginning.
Before this tip appears I'll say it: Automatically Populate Toolbox is True. Nothing helps against this problem. Build Project/Solution, Rebuild, Clean+Rebuild, Restart of VS, Restart of Computer, Unload and reload the project, set toolbox back to default. Nothing works.
Any ideas??
You have to remember that the designer call your code constructor and some other methods at design time.
If you build the code and the control does not appears and it has not been hidden by an attribute, then probably the code you wrote is not compatible with the designer. For example, the control might throw an exception in design mode because of incorrect code.
The attribute is [ToolboxItem(false)]. If you have a base class that hide it, it will also be hidden in derived class if not specified otherwise.
You will have the same problem if that control is used in another component. You won't see it if it does not compile and run correctly.
The trick to debug that kind of problem, is to attach a debugger from a second instance of Visual Studio to find where in your code you throw an exception.
If the control does not work at run-time, better to fix that first as if it also fix design problem, it is simpler to debug that way.
Otherwise, you have to ensure that your project dependencies are correct. The toolbox will only shows component from DLLs that are referenced by the current project (or from itself I think).
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
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.
Has anyone else experience incredibly slow performance in the XAML editor in VS 2010? If I have a new project with a limited number of files, the performance is fine. However, if I have a project with a larger number of XAML files, the XAML editor hangs intermittently every few seconds, making it almost impossible to use.
I should also note that the performance is only slow in one particular project where I am referencing DevExpress 2010. I am not certain if this is related.
Any suggestions on solutions to this problem would be greatly appreciated.
Chris
In Visual Studio 2012:
Go to
Tools > Options > TextEditor > XAML > Misc
Check Always open documents in XAML view and uncheck Automatically populate toolbox items.
In Visual Studio 2015, 2017:
Go to
Tools > Options > XAML Designer
uncheck Automatically populate toolbox items.
This fixed my same problem.
If you don't need the visual designer, you can select a different editor in visual studio:
Right click the xaml file -> Open With... -> Source Code (Text) Editor
You will only lose the split view, intellisense etc. should still work.
If you need to check something in the designer you can still click 'view designer' to open the normal XAML editor again.
If you want to improve the performance of the visual designer, try checking DesignerProperties.GetIsInDesignMode in your code-behind. The visualiser instantiates your controls to know how to display them, thus executing parts of the code-behind.
Like the OP, I had extreme lag in the xaml editor on a project that relied heavily on DevExpress WPF controls. After trying unsuccessfully to resolve this issue with the other solutions posted here, I eventually tried deleting my Solution User Options (.suo) file, which is usually located in the same folder as the solution (.sln) file. This immediately resolved the issue. You may want to read this post about what visual studio stores in the suo file so you can reset anything important (such as build configuration - mine always defaults the active solution platform back to "Mixed Platforms" for example)
Short answer: if you do not use designer much, just replace the default editor for XAML, thus getting rid of XAML visual designer and speeding things up. Right click any XAML file, click Open with... and choose another default editor. Source code (text) editor works just fine.
Now it should be already fine. If you want to understand the details and completely get rid of the slow designer, read the long answer.
Long answer: Here is a nice explanation of what happens and why is it that slow.
A brief todo based on the aforementioned article in order to completely disable the visual designer of XAML:
Under Tools->Options->Text Editor->XAML->Miscellaneous->Default View check Always open documents in full XAML view
Open Task manager and end XAML Designer process XDesProc.exe (Note: for VS2013 right click this process and go to containing folder. Rename the exe to sth else, than end the process)
Standard XAML editor will load this process again (I guess it will not succeed with VS2013 and actions done in P.2). However, right click any XAML file, Open with... and choose another default editor. Source code (text) editor works just fine.
While using dev express, I've noticed some laggy response in the Visual Studio designer. This appears to be due to the license authentication of the DevExpress products.
If you delete the "Licenses.Licx" file (found in the project properties folder) you'll notice a marked improvement in performance.
Note: Removing the license file doesn't stop you from using DevExpress controls. But it does stop VS from constantly authenticating it.
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.