Win8 - Unhandled exception in Windows.UI.Xaml.dll - winapi

I've got some strange behavior while debugging/running my metro app.
During drag'n'drop the screen will be refreshed. I'd added some functionality to block binded properties from refreshing while drag'n'drop is in progress.
But sometimes the app crash, but in stead of throwing some exception which I can debug, all I got is an window saying to open an external just-in-time-debugger
An unhandled win32 exception occurred in SOME_APP.exe [7785].
(The external debugger does not bring more information)
And the output says:
Unhandled exception at 0x05017145 (Windows.UI.Xaml.dll) in SOME_APP.exe: 0xC0000005: Access violation reading location 0x00000088.
I'm working on a x64 device.
Has somebody ever heard of such problem?

If you're passing objects implemented INotifyPropertyChanged, inherited BindableBase or DependencyObject etc. thru NavigationParameter; and bind then in the NavigatedPage (or binded them in the navigating page) you'll most likely get this error. Don't pass any object except primitive type thru NavigationParameter when navigating.
You are getting this exception because non-existent referenced methods. For example.
You have an object named Categories which inherites BindableBase.
You binded that to Home.xaml.
Home.xaml's binding mechanism subscribed the PropertyChanged event of Categories object.
You navigated the Article.xaml passing Categories object as a the NavigationParameter.
You binded the Categories object to Article.xaml.
When a property changes in Categories object; that property will fire PropertyChanged event.
There are two subscribers to that event. Home.xaml and Article.xaml, but Home.xaml is no longer exist since you navigated away from it. But your delegate holds the address of it; so it tries to Execute; and fail with Access violation error.

Related

How to properly setup widget for background update on macos?

I'm building a widget for macOS, which is target for macOS only. And, it keeps crashing after an attempt to recreate another timeline (from getTimeline function)
It throws the following error:
Terminating app due to uncaught exception 'NSFileHandleOperationException', reason: '*** -[NSConcreteFileHandle fileDescriptor]: Invalid argument'
terminating with uncaught exception of type NSException
I believe it is generated due to the lack of implementation of the method onBackgroundURLSessionEvents(matching:_:), which brought my attention to the following documentation ⬇️
From Apple doc :
When your widget extension is active like when providing a snapshot or timeline, it can initiate background network requests. The process is similar to how an app handles this type of request, which is described in Downloading Files in the Background. Instead of resuming your app, WidgetKit activates your widget’s extension directly. To handle the result of the network request, use the onBackgroundURLSessionEvents(matching:_:) modifier to your widget’s configuration, and do the following:
Store a reference to the completion parameter. You call the completion handler after processing all network events.
Use the identifier parameter to find the URLSession object you used when initiating the background request. If your widget extension was terminated, use the identifier to recreate the URLSession.
After invoking onBackgroundURLSessionEvents(), the system calls the urlSession(_:downloadTask:didFinishDownloadingTo:) method of the URLSessionDelegate you supplied to the URLSession. When all events have been delivered, the system calls the delegate’s urlSessionDidFinishEvents(forBackgroundURLSession:) method.
To refresh your widget’s timeline after the network request completes, call the WidgetCenter methods from your delegate’s implementation of urlSessionDidFinishEvents. Once you finish handling the events, call the completion handler that you previously stored in onBackgroundURLSessionEvents().
The problem is that urlSessionDidFinishEvents(forBackgroundURLSession:) is only available for:
OS 7.0+
Mac Catalyst 13.0+
tvOS 9.0+
watchOS 2.0+
It seems like there is no equivalent idea for macOS targets. So, how should we set it up?

THREAD 1 SIGABRT error

I just started with Xcode programming and I encountered my first problem when I run my app without any extra codes, methods, properties or classes. I started with the template SINGLE VIEW and I changed the .xib to MainWindow and added an object called basically App Delegate. I removed the single view object from the MainWindow.xib and replaced it with a UIWindow.
I receive the following classic THREAD 1 SIGABRT error:
App[4178:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ViewController" nib but the view outlet was not set.'
*** First throw call stack:
(0x14f8022 0xef8cd6 0x14a0a48 0x14a09b9 0x1222dd 0x122779 0x12299b 0x81401 0x81670 0x81836 0x8872a 0x1ff5 0x59386 0x5a274 0x69183 0x69c38 0x5d634 0x13e2ef5 0x14cc195 0x1430ff2 0x142f8da 0x142ed84 0x142ec9b 0x59c65 0x5b626 0x1d2d 0x1c95 0x1)
terminate called throwing an exception(lldb)
I already reviewed existing postings, but I could not get wiser on it.
It seems very confusing, but is actually very simple. The Thread1: SIGABRT glitch means that something is interrupting your connections.
This may be caused by declaring your connection as weak, and declaring it as strong in your code. In order to tell what you declared your connection by clicking on the object that is having the problem, and then going to the connections inspector (the symbol with a circled arrow). This will let you see the connection.
Now try changing your code declaration from strong to weak (or the other way around), then running your program. If this does not work try deleting the code of the entity, and deleting the connection by hovering over it in the connections inspector and clicking the "X" that shows up.
After deleting the connection, and code try reconnecting the entity and the code should reinstall by itself.

how to handle when either of view or partial view fails with global handler

I have implemented global error handler using exceptionfilter in my application. This global handler finds and loads error message to temp data. The application have error control to show these error messages from tempdata. This works fine when any of my partial control fails.But when entire view fails, there is no view to show error control as the view had error and hence the 500 Internal error is shown in the browser.
To avoid this I tried using . I specified defaultRedirect. I have defined a route for the same and then implemented an action on controller. But the problem is this won’t work as the global handler gets called on exception, this global handler sets the ExceptionHandled=true.
Now If I don’t mark ExceptionHandled=true, then the Action mentioned in defaultRedirect gets invoked. This is fine if entire view fails.But when a partial view fails then also the error view will always be shown since ExceptionHandled is not set in error handler so it default redirects as well.
Please suggest me how this can be tackled. I want the error control to display on page when partial control fails and want to show error view when entire view fails.
Please revert soon.
.

Error hosting Silverlight application page with WCF service

I am currently developing a Silverlight application with WCF service. The process flow of my project is as follows.
Silverlight page -> Service1.svc -> SQL Server 2008 and back
What my Silverligth page does is when a user clicks a button it calls a service reference (Service.svc). What the service is doing basically is to query a SQL database (SQL server 2008) and return the query back to the service and in turn the service returns the result back to the Silverlight page where it will be displayed.
When I am debugging and running the webpage from the visual Studio 2010 express all the things go according to plan i.e. when the user clicks the button the data that were acquired from the database are displayed.
But when I try to publish this and run it on Apache server or IIS I am getting an error when clicking the button. The web page is displayed correctly even from another internally connected PC, but the problem occurs when I press the button.
An error message is displayed as shown below:
An exception occurred during the operation, making the result invalid. Check InnerException for exception details.
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at SilverlightApplication11.ServiceReference1.DoWorkCompletedEventArgs.get_Result()
at SilverlightApplication11.About.client_DoWorkCompleted(Object sender, DoWorkCompletedEventArgs e)
at SilverlightApplication11.ServiceReference1.Service1Client.OnDoWorkCompleted(Object state)
-------------------------------->
I have abosolutley no idea on how to solve this. I am very new to this whole stuff please help I been stuck in this about a week now.
Any snippets of code you guys would like please comment so I can post it here.
Thanks in advance =)
The service call you're making has an equivalent event to tap into. Your handler will be called when the operation completes or fails. The event args passed to your handler will contain information about your error. Keep digging into inner exception until something makes sense.
Also, your silverlight's App.xaml.cs has the ability to do something when an exception is thrown. There's an event called UnhandledException you can tap into. From there, you can output more information for yourself about the InnerException. Sometimes the first exception is not helpful, but there will be an InnerException in the Exception that will have more detail.

How to watch for UNHANDLED exceptions only using WaitForDebugEvent family functions?

I'm trying to catch unhandled exceptions in the application and restart it on them using WaitForDebugEvent function. But I can't tell when exception is handled by application (try..catch for example) and when is not. How do I do that? There seem to be no such data in DEBUG_EVENT structure.
If your not catching certain exceptions using WaitForDebugEvent, you might want to try injecting an UnhandledExceptionFilter as well. other than that, check that your processing matches Microsofts Example
In the EXCEPTION_DEBUG_INFO structure, which is in the DEBUG_EVENT structure, there is a field dwFirstChance:
If the dwFirstChance member is nonzero, this is the first time the debugger has encountered the exception. Debuggers typically handle breakpoint and single-step exceptions when they are first encountered. If this member is zero, the debugger has previously encountered the exception. This occurs only if, during the search for structured exception handlers, either no handler was found or the exception was continued.
So you will want to look for times where dwFirstChance is 0.
But if you just want to restart your app when it fails, it might be easier to create another app to watch for the failure of the first one, rather than using the Windows debugging api.

Resources