My application is working fine, all of a sudden while loading a designer in wpf form, im getting errors.
Object reference not set to instance of an object.
As if it is in a loop. After pressing the enter button for sometime. Im getting this error.
Microsoft Visual Studio XAML UI Designer has stopped working.
And after this, im getting this.
System.Runtime.Remoting.RemotingException
[9980] Designer process terminated unexpectedly!
The number in square brackets is changing evrytime.
Im using Visual Studio 2012. Im not yet running the application, Im just switching to designer mode from code behind. If I compile and run the application, it runs fine.
Kindly help.
Edit:
Here are the three errors in single image. (I cant post morethan one link)
xamlerrors
There's an error either in the code-behind or DataContext (if you're using a ViewModel). After you fix that error, click on Click here to reload the designer. What's happening is that the designer is trying to load everything up during design time and since there's an error, it's unable to, as if the program was actually running. That null reference exception can be a bit misleading in terms of trying to figure out the cause, because it'll be thrown if you have an error in your code-behind or ViewModel.
Things to check:
Is your View referencing the correct ViewModel?
Is your code-behind portion of the View matching the View name? Some people copy their Views, but forget to change the Class name in the code-behind.
Do you have any errors in your ViewModel?
What about models? If they're loaded during design time and contain errors, this could cause the above exception.
I noticed that those kind of errors are almost everytime caused by
an error in the parameterless constructor of the view
an error in the constructor of the view model which is attached to the view
Keep in mind that when the designer loads, it calls the parameterless constructor of the view (there has to be one for the designer!). If there are "complex things" done there which can only performed correctly at runtime, there will likely be errors at design time.
The same is true for the constructor of the view model which is called from the view.
Check whether design mode is active
For example you should not load data from a repository in a constructor.
If you do it in the constructor, at least check whether the design mode is active or not like explained in this answer here about the GetIsInDesignMode attached property and only do the complex logic in the constructor if the design mode is not active.
Debugging the problem
You also have the possiblity to debug the problem. In order to do this, you have to open a second instance of Visual Studio and debug the designer process of your original Visual Studio instance from there.
The process is described in detail here: Debugging an Exception (only) occurring in design view
Related
Why is it that every time I open a user control or anything a little more complicated than simple markup, Visual studio is unable to display it in the designer? Sometimes I have a form where there are several elements, but all the designer displays is a rectangle? How does one work on more complicated pages with XAML?
If you use Binding in XAML, VS designer invokes the binded object as a compiled manner like part of your program being executed. At this time, if the binded object does not prepare any fake data programatically which gives null in general, VS designer is failed to render UI because it is treated as NullReferenceException during rendering process.
Those fake data is called design-time data in XAML.
To prepare design-time fake data for UI, please check this link: https://stackoverflow.com/a/11561369/361100
In my experience, Visual Studio's designer is almost completely useless for anything more complicated than the simplest designs. Have you tried using Blend? It actually works (most of the time.)
I have a WPF application which is giving me a very very annoying error
System.Runtime.Remoting.RemotingException
[12068] Designer process terminated unexpectedly!
The number between [] changes each time
The XAML is very simple
<UserControl x:Class="STC.Reports.ReportGenerator.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</UserControl>
This has wasted me hours and hours
Does anyone know anything that could help?
I cant get any more information than that above
Even though I have told VS to break on these Exceptions it doesnt
I have also tried to attach another VS and that makes no difference
I have repaired my installation of VS (2012 Professional)
I have also updated to Update 3
This is even happening when I create a brand new WPF application
Everything seems fine initially, then VS just hangs and the remoting error occurs
Paul
What kind of message are You getting?
If it is a Messagebox when You try to use designer - it is a known issue since VS2010 as far as I remember. It is frequently caused by a video card or its driver, so the easiest way is trying to update your video driver or use some older version. Sometimes that help.
The other way is not to use built-in designer. As for me, I wite pure xaml and it seems to be more convenient and faster way of development. Or, if You like visual UI - You may use Blend. AFAIK it is a part of VS2012 now.
I had this error occur for all windows/controls in a project, even if they were brand new empty windows. I had a markup extension causing a design-time exception (with no indication of this from Visual Studio) and I would get this designer error if I used the markup extension in any project resource dictionaries.
Old post but might be useful for future developers who run into this kind of problem.
I had this exact behaviour. Turned out to be a problem related to my viewmodel. At runtime everything works, but at design time VS will try to load the viewmodel standalone and things got haywire. My viewmodel depended on some global object which I created elsewhere at application startup. Loading the viewmodel standalone creates a exception since the global object was missing.
Quite easy to detect actualy. Just test your viewmodel by instantiating it yourself from code. If it fails VS won't be able to run the designer as well and as you see VS unfortunately won't tell you what happened.
As the title suggests, this error is thrown by the designer, which means the designer can't display my UserControl correctly which in turn means I can't navigate smoothly from element to element in this UserControl to make modification. Really annoying.
XXX is the name of my UserControl, while the URI YYY is actually XXX's path. So I don't know understand it can't find itself as resource. I googled this error, but most of them happened in the runtime. In my case it doesn't happen at all when I execute it. The description of this error is really not explanatory enough, because I am not sure who in the CLR is loading the file itself as a resource.
Another thing might be worth mentioning is, this error only happens after I build my application project, which the error UserControl resides in. After I click to clean the project, the designer can display the whole stuff (but obviously I can't clean the project every time before I make any change, since the building takes time)
It is possible that the control's .g.cs or .g.i.cs file has been corrupted. Try to clean, close visual studio and restart it. I think that helped for me in several cases especially when I copy paste controls from one solution to another.
Just delete subfolders in
%LOCALAPPDATA%\Microsoft\VisualStudio\12.0\Designer\ShadowCache
If you refactor a UserControl down a lower level project that the UserControl was previously referencing then you will see this error.
Removing the assembly reference from the namespace fixes the issue.
<UserControl xmlns:ui="clr-namespace:MyCompany.Core.UI;assembly=MyCompany.Core.UI"
should be
<UserControl xmlns:ui="clr-namespace:MyCompany.Core.UI"
The designer is not smart enough to highlight this.
I ran into the same issue, it compiled and ran fine, but the XAML editor/Designer complained. In my case, I found the solution to be that my user control was declared within a namespace in the XAML (x:Class="myNamespace.myUserControl") but not in the code behind. Adding the namespace declaration in the code behind solved my issue.
There is a possibility to debug Visual Studio Designer in the second attached Visual Studio.
See How to troubleshoot and debug Visual Studio design mode errors for details.
To display the UserControl, the designer has to instantiate the user control. Look for possible Null Reference Exceptions.
In my case the user control had an NRE due to a dependency not being injected. I added handling for the NRE and no more issue.
I've been working on a SL5 app for a few days. I've mostly been using a hard coded dummy data collection when styling my app's view. Everything has been working fine, but now I want to connect it to a dynamic data collection generated by my view model (using the data service technique where you have design time & real data depending on the IsInDesignTool property.
After I cleared out the control of the hard coded data and bound it to a collection in my view model. When I run it in debug mode, I see an unhandled exception being thrown in App.xaml.cs. The exception args don't say exactly what the problem is (it is simply saying "Value does not fall within the expected range" but when I look at the sender I find the following coming from the MainWindow (my app only has a single view): "Out-of-browser specific settings do not affect in-browser applications."
Further, when I try to view the MainWindow in the designer in VS, it doesn't render and instead shows an error (the rendered exception in the designer doesn't have any of my namespaces in it, just things about controls & UIElements).
I'm at a bit of a loss how to troubleshoot this. I didn't set anything for out-of-browser when building the app and since it worked with dummy data collections, why would it suddenly have this issue (seems like if I was using an out-of-browser property it would have shown up before I bound the data to the view).
Tips/pointers?
(sorry for my bad english)
I am not sure on what is happening but I saw the error "Out-of-browser specific..." when I tried to access some specific property only available to OOB while running on browser. The solution was to test if running oob before using the property:
if (Application.Current.IsRunningOutOfBrowser)
{
Application.Current.MainWindow.WindowState = WindowState.Maximized;
}
The other problem possibly is unrelated - and sometimes can be really hard to debug - one thing that helped me is to open another instance of VS and attach it to the one where you are seeing the problem. With this setup, go to your problematic View and change to "design view" - keep an eye on the Output window of the attached VS to see if some meaningful exception is shown.
I had a similar issue.
I did put a Textbox inside kind of Listbox (radPanelBar) and added
HorizontalScrollBarVisibility="Auto" to the Textbox. It seems that the textbox had problems when to show the scrollbar and when not. Adding
ScrollViewer.HorizontalScrollBarVisibility="Disabled" to the Listbox did solve it ( so, no OOB issue at all ).
I'm not entirely sure what the error was, but it wasn't at all realted to OOB. I'm using a data service approach (in design time I programatically build real data, not the Expression Blend sample data, but when not in a design tool, it uses the REST services). I started disabling a lot of things in my dynamic data and slowly added them back. Somewhere along the way my dummy data generation was fouling things up, but SL thought it was an OOB issue.
I have an WPF app, all seems to run fine with one exception - the designer rarely, if ever, loads correctly. Usually complaining about Undefined CLR namespace. and then saying it can't find a few of my local: defined controls.
Is this just a defect in the designer or Visual Studios code generation or actually systemic of something wrong with my application?
In your code can be an error which occurs only in design time. It is possible to debug it. See How to: Debug a Designer Load Failure. Shortly you need another instance of Visual Studio and attach it to the one displaying your wpf app. You can even try to follow the error to its roots with How to: Debug .NET Framework Source.
I had a similar problem and I successfully tracked it down to DataContextChanged event handler and got rid of it.