Debugging Silverlight Bindings - silverlight

I have a binding in Silverlight that is causing my application to exit. An unhandled exception is not throw; I just get a white screen.
I am not seeing anything from the binding engine in the output window.
Does anyone have any ideas for debugging this issue?

I suggest you use Karl Shiflett's Glimpse for Silverlight for that.
Also, I just "heard" Laurent Bugnion on twitter recommend using a mock Converter on a binding to figure out why it's failing. That's a good idea in case you're unsure as to what values are being fed to the binding.

Dave, dont get too excited about the XAML debugging in SL5. I have been building projects for a few weeks now in SL5 and all I can say is that the XAML debugger will break after very little use and all you will get back is the ridiculous error message saying that the PDB's cant be found. I have reset my VS2010 setting numerous times and still the debugger remains crippled. I have spend days if not weeks trying to get to the bottom of the cause and as usual there are no support documents or help sites for this issue. Debugging Silverlight databindings is a black box scenario and a huge weakness in this technology. There is no way of knowing what the XAML parser is doing or not doing as the case may be. I have just had to scrap a project because of a total failure of the bindings in the View. The VM is preforming correctly by all bindings on the view fail. People will tell you that the output window in VS2010 will indicate the binding errors. My experience is that you can have total failure of bindings and NO errors will be shown in the output window. If you get into this scenario there is simply no solution that I am aware of and even the bug ridden XAML debugger wont be able to help you.

Related

System.Runtime.RemotingException in simple XAML file

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.

Strange rendering error in SL app... out of browser 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.

How do you make developing a XAML based UI bearable?

I enjoy developing for the web, HTML/CSS/JavaScript are easy to debug and see what is going on with tools built into modern browsers such as Chrome/Firefox and simple things such as view-source
But with WPF, I'm constantly getting into moments where I think something should happen and it just doesn't. I eat up a lot of time in frustration trying to figure out why a damn button is a certain color or text isn't showing up, etc, etc.
How do you make WPF bearable? Am I missing out on any tools? I know I can prototype in tools such as kaxaml but it doesn't always translate into the real thing.
I want an "Inspect element" when doing WPF!
Snoop is the closest thing to Firebug you're likely to get. One thing I can't stress enough though is to watch the Output window while the app is running - it will tell you when styles/brushes/whatever fail to load.
Also, if you're working in a big project and are having issues with a control or style, pull it out to a separate dummy solution and see if the problem persists. XAML isn't as bad as CSS when it comes to weird inheritance issues, but it can really help you see what's going on.
I want an "Inspect element" when doing WPF!
I would recommend trying Mole 2010. It includes a visual inspector for WPF applications.

Troubleshooting WPF / Silverlight XAML databinding?

Whenever I am doing XAML, I tend to run into problems with databinding. It is often small issues, such as misspelling a property name.
My problem is, that I don't seem to receive any errors or warnings when I am trying to bind to a property that does not exist. It would be nice to get a warning, either at compile or runtime, about my errors.
Is it possible to get a warning about wrong databinding expressions ? What do you do to troubleshoot when your data does not appear as expected ?
WPF will write warnings about problems in data binding to the Visual Studio "Output" window
This blog post, How can I debug WPF bindings? helped me learn why my Binding was failing.
I've accepted the other answer to this question because it is technically correct, but I wanted to include the link above in this question, for future reference.

Attempted to read or write protected memory

I am trying to learn WPF. I am following along with a book(WPF in 24 hours) and occasionally I get the following error:
Attempted to read or write protected memory. This is often an indication that other memory has been corrupted.
When I click "OK" the application continues to run as if nothing is wrong.So far I have worked with XAML only and have not entered any other code. The examples that I have found so far in SO and google reference specific code issues. Any shove in the right direction would be appreciated.
Oh...I am using VS2008 Pro
I had this when declaring a Style without specifying the TargetType. I cannot remember if that was in WPF or Silverlight2 though.
Old question, but in case it helps someone...
I had this error as a build error in a XAML file of a Template10, MVVM UWP app.
The reason appears to be because I was referencing a ViewModel that is in a separate .dll.
Moved the referenced ViewModel into the app, the build error goes away.

Resources