Unknown error caused by DataTemplate - wpf

Since a few days back the WPF editor no longer works. Whenever I click somewhere in any editor it becomes disabled with this message:
'NullReferenceException was thrown on "DataTemplate": ... (etc.)'
I have spent a few hours trying to locate the problem without success so if anyone could give a hint on where to look I would greatly appreciate it.
I have tried to debug with CLR exceptions enabled when thrown (VS2010->Debug->Exceptions...->Common Language Exceptions (Thrown) 'Checked') but I get no exceptions from it.
Apparently there's a problem some DataTemplate somewhere that's only showing in design time but I just can't figure out how to locate it.
Cheers

I finally traced the problem to a small markup extension I wrote. Having removed it the DataTemplaring system stopped behaving badly.

Related

CheckBox.setToggleButton doesn't exist

i have been trying a code found here to add rating bar but i got an error on
cb.setToggleButton(
where the "setToggleButton" method didn't or doesn't exist anymore
any idea if it has been update cause the post i tagged was back from 2014
That method doesn't exist, it should be setToggle(true). Notice in the linked post it just said setToggleButton( without even a closing bracket. Since this was written a while back I'm guessing I just switched a desktop to check the method name and got distracted then forgot to fix that. Hazards of blind coding without the comfort of an IDE.
#devcrp actually wrote the correct answer before but unfortunately he deleted it. If he undeletes it his answer should be accepted.

Arg_COMException Error in Silverlight 5

One of our clients suddenly got an Arg_COMException since last Wednesday (30th Aug 2017).
Here is the error message with the stack trace.
[Arg_COMException]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.50907.00&File=mscorlib.dll&Key=Arg_COMException
Stack track: __________________________________
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports...
...
Here is the full error message
Any help would be highly appreciated as this is a production issue.
We identified, some of dropdowns and AutoComplete is causing issue while loading. So hide those controls and make it visible after a short delay one by one. Now the form is functioning. This is kind of workaround.
Still no clue what is causing the issue and what could be the correct fix.
Thanks
If you have a Extended ASCII charactors in your XAML or in your data, you may get this error.
In our application we had a one extended ASCII charactor in our XAML which looks like hypen ( '-' ). We assumed it is just an hypen (or minus) charactor. This is causing issue in our application. After changing this, the issue is resolved.

CakePHP: Error: Database table cake_errors for model CakeError was not found

I have a CakePHP error and I having a hard time to trace the problem. Hope you can help me.
Here is the error message:
Missing Database Table
Error: Database table cake_errors for model CakeError was not found.
Notice: If you want to customize this error message, create app/views/errors/missing_table.ctp
Am I missing something here?
Thanks in Advance.
Cheers,
Mark
Its hard to tell why exactly without seeing the code firsthand, one trick i have used with theese kinds of errors though is making "app/views/errors/missing_table.ctp" as inserting the following code
<?php pr( Debugger::trace() ); ?>
This will will help workout what you called to cause this issue in the first place.
I realize this question is 4 years old, but since I bumped into the exact same problem and found no information about it that could explain where the error is coming from, I did some digging of my own and come up with some clues that I include here in case it helps.
My AppController beforeFiler() method, amongst other things, uses a function that checks if the Model of the Controller has enum fields (I know... I know...) and handles them "properly".
When an error in the application triggers an Exception (Nothing fancy... a "Missing Controller" does it) and the debug level is 0, the CakeErrorController tries to render the exception and it fails because there's no cake_errors table, generating an endless loop that ends when PHP runs out of memory.
I fixed this by improving the detection of whether the main Model of the controller is indeed using a "real" table.

How to Debug XAML Parsing Errors in Silverlight?

I run into the following issue semi-regularly: I make changes to XAML or some resources used by it and when I go to load up the Silverlight project in debug mode it only gets as far as the spinning Silverlight-loading animation.
I've tried attaching the VS08 debugger to the process but it doesn't do anything at this point (works fine once I'm in the Silverlight but not before.)
From previous experience I've noticed this happens when there're problems with the XAML or the resources in it but my only solution so far has been to dissect the code line-by-line until I spot the problem.
Is there an easy way to debug/diagnose these situations?
UPDATE
I found this question with some help, but it still doesn't provide a good way to debug these types of issues.
This has been a real pain to debug but I finally found the problem hidden deep in the constructor to one of our custom controls (which was looking for a resource that wasn't there.) The real problem isn't fixing the issue but finding it.
I found that IE responds to exceptions in passed from Silverlight to the DOM but you don't get that same sort of feedback in the Chrome browser (which I use.) A solution that actually helps a great deal (even moreso than the IE tip) is to modify the ReportErrorToDOM() method in App.xaml.cs to the following:
private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
{
string errorMsg = String.Empty;
try
{
errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", #"\n");
System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
}
catch (Exception)
{
#if DEBUG
MessageBox.Show(errorMsg);
#endif
}
}
This gives you the position in the XAML where the issue is starting. It's not an ideal debugger, but it does help.
This is not the ultimate answer but can often help
In Visual Studio :
Click Debug > Exceptions
Click 'Find' and search for XAML
Click the 'Thrown' button next to System.Windows.Markup.XamlParseException
Start your project in debug mode. Any Xaml exceptions will be shown immediately. Check the inner exception sometimes for further information.
I wasted soooo much time before I finally figured this one out!
This may not apply, but one frequent source of XAML errors is due to uncaught exceptions within converters that you're using as resources. People often forget to use a try-catch block in their converters, and when something blows up in there you end up having to dissect your code line by line.
And, take this with a grain of salt, but depending upon the situation, you may be able to copy-and-paste some of your XAML into a WPF project and get better error messages. I've never relied on this tactic myself, but I recently heard about it from an experienced WPF/SL developer who's far smarter than me, so it might be worth a shot. :-)
Per microsoft: The end user at this time cannot debug the XAML Parser, only MS can do this. The new version of Silverlight 4 XAML Parser has been completely re-written using managed code and hopfully they will give us a better way to debug it. I know this as I just had an issue and opened a support case and was informed this by a Silverlight Dev.
The clkosest I could ever come to seeing what was going on with the parser was using Silverlight Spy:
http://firstfloorsoftware.com/silverlightspy/download-silverlight-spy/
Great tool.

Silverlight 3 XamlReader Exception not caught

when I use XamlReader.Load() with an invalid XAML string, the resulting XAMLParseException is not caught although beeing in a try-catch-block:
try
{
UIElement xamlCode = XamlReader.Load(XamlText) as UIElement;
}
catch (Exception ex)
{
ErrorText = ex.Message;
}
The code is called from the Tick-Event of a DispatcherTimer, but also in Events like MouseLeftButtonDown the exception is not caught resulting in a break in the Line where I call .Load().
Does anyone know how to catch this Exception and resume normal programm activity?
Thanks, Andrej
It is completely unfathomable that this code would not catch the exception. How do you determine that the XAMLParseException is occuring here? Are you sure is not coming from some other Xaml Load in the project?
Is this always the case ? or onlys while debugging ?
I'm aware this is an extremely late answer and you might have found the solution to it, for as reference to people finding your question similar to theirse (like my case ), my answer might still be of use.
If its happening while debuggin, it might be because the exeption is configured to be thrown.
You can change this:
Customize the Debug menu, adding the "Exceptions" command to it.
In the Exceptions configuration, Drill down to System.Windows.Markup.XamlParseException, which is under Common Language Runtime Exceptions.
Remove the check from the "Throw" column.
There are various Silverlight operations that get "re-marshalled" onto separate threads for what are presumably various good and sufficient reasons. It looks kind of like this:
Dispatcher.BeginInvoke(() => LoadSomeXamlOrSomething());
Any exception thrown within LoadSomeXamlOrSomething() won't be caught by normal try/catch blocks. This happens even in SL 4 with things like loading images with invalid formats. It's annoying, and MS needs to come up with a better way to handle this, for instance, by letting you register an exception handler when you make the call.
Until MS figures this out, your options are:
Fix the underlying XAML error.
Catch the exception in App.Application_UnhandledException.

Resources