Windows Phone 8.1 App Crashes When Not Debugging Async Await - c#

I am working on a Windows Phone 8.1 application. I am about a month into the project and have seen little to no issues with what I have written so far.
I decided to do some testing on the application without running it through the VS 2013 debugger. Now, for some reason, the app crashes before it gets to the first screen. I get no exceptions or messages whatsoever(I am using Raygun for error logging).
I am using async methods throughout(some async void, others async Task), but all of this works when debugging.
The main thing that would help, is to get some sort of error message. I've been reduced to commenting out sections of code, but ultimately this is getting me nowhere because it seems when I think I've found the issue, I get another crash further down into the code.
At one point, I found an issue with calling: ListView.UpdateLayout(). I commented this out and the app would run properly no crashes. I then un-commented some code further down and now it's crashing again.
If anyone knows of a way to get exceptions from the phone or if someone has experienced this issue before, any help would be greatly appreciated. I can provide any further information that is needed.
UPDATE:
I think I have narrowed the issue down to Sqlite.NET. I am using Sqlite.Net for WinRT along with an extension called SqliteNetExtensions. The particular statement is
DataContext.Context.Connection.Table<Message>().Where(m => m.ChannelID == channelID && m.ChannelID.Contains("C")).ToList();
If I comment this out, the app runs with no problems. This LINQ statement at most returns 100 records. I would not think that a 100 record SELECT statement could cause the app to crash, but it seems like the culprit. Any ideas on how to optimize Sqlite.NET?
UPDATE 2:
Finally figured it out! It was not SQLite at all. It was not my code at all. It was my phone. I am running a Nokia Lumia Icon. I had installed Rudy Huyn's Lockscreen Beta a few weeks back. It caused some issues when I uninstalled it but it wasn't related to my application. Today, I had my business partner install my app on his phone, he has the same model phone. The app was about 50x faster and did not crash. I restored my phone from factory and, lo and behold, it ran perfectly. So, pro tip: DO NOT INSTALL LOCKSCREEN BETA BY RUDY HUYN!!!

As an aside, I would take the time to ensure you always avoid using async void. It is well documented that async void is often a recipe for trouble.
There is a good article on the disadvantages shown here

Related

C# UWP BluetoothLEDevice.FromIdAsync stop working

I'm developing a Bluetooth app using UWP framework under Visual Studio 2017. Everything is going well thanks to Microsoft Example (C# SDK Example BluetoothLE well written).
During my fourth day of development, the API BluetoothLEDevice.FromIdAsync in the line:
bluetoothLeDevice = await
BluetoothLEDevice.FromIdAsync(bleDeviceToConnect.Id);
Is no longer working, neither in my app, neither in the original sample from Microsoft I'm using as example (I don't touch anything on it).
I don't understand as I changed nothing (in my project properties, neither any Windows update on my computer). When I call the function, it just never return.
I tried my Bluetooth object used with some smartphone app, and my hardware is working well.
The call is made in a try but no exception is catch, the function just never return (and I wait some time, I don't even have a timeout).
Have you seen this? Any input on how to solve it?
I'm totaly stuck and can't go ahead as I can't connect at all any object now...
If your code and the example code are having the same problem, the only reasons can be that your device is not available.
It is out of reach or even switched off or already connected.
It can also be that if you are using the deviceManager or deviceWatcher, your OS is providing stale information.
For BluetoothLE the windows deviceManager and watcher are nothing but trouble.
Windows sometimes keeps the pairing information and connection status, even if the device is out of reach or switched off.
Many times you have to remove and and re-add your device in settings to make it available again or a restart is needed.
To save you from all these troubles, I advise you to use the advertisementWatcher.
If your device is found by the advertisementWatcher you know it is in reach and connectable, and there is no need to add your BLE-device in settings.
If needed I can provide a simple example.
This may happen because of COM security (as you may know UWPAPI based on WinRTYY which works above COM). This should help.
Hello All and thank you for your help on this.
I got a shot on an other computer and it works just fine.
I double check this morning and found out that even Widnows can't connect to anything over Bluetooth (I tried with the Bluetooth Speaker I'm usually using).
It was a Driver issue, I don't know how it happens, but my computer Driver just stop working, and I add to reinstall it.

UWP Xbox One difference between running in Retail to Dev Mode

I am having severe problems getting an app working in Retail Mode on the Xbox One.
The app works fine in Dev Mode, I have uploaded to the store and it passes certification fine but when the app is then installed via the store onto a Retail Xbox One it refuses to run.
Firstly it was crashing whilst on the splash screen, no error message just returning back to the Xbox homes screen, Due to now being in Retail mode I cannot connect a debugger to the app. I've setup my own exception handler to send errors to my backend server and it was crashing with the exception:
Cannot create instance of type 'Microsoft.Advertising.WinRT.UI.AdControl'
It's using the latest Microsoft.Services.Store.SDK and therefore Microsoft.Advertising SDK for XAML.  I've took out the AdControl from MainPage.xaml and now we have a UI come up on screen! Not ideal as the ads are needed for monetization.  
Unfortunately that's not the end of the problems, during the app initialisation it copies files from the Data folder of the solution to localstorage, for some reason it's now hanging on the following:
StorageFile anjFile = await localCacheFolder.GetFileAsync(App.AbilitiesFileName);
What's so different running apps on the Xbox in Retail Mode compared to Dev Mode? The app also functions fine on mobile and desktop so I know there shouldn't be any problems. The only way to try and find out what's causing problems is to comment out lines, or put placeholders in the app to change a debug textbox on screen to see what part of code is running and rebuild and submit to the store again, wait for certification and then redownload from the store to the Xbox, a very slow and time consuming task and I'm now up to Submission 12 of an app I'm getting very frustrated with!
Update: Seems like the AdControl issue started around 9th Feb and is affecting several apps on Xbox One and is possibly due to a framework update to the libraries involved. Not sure why it isn't affecting Dev Mode as well.
Thanks a lot for reporting this issue out on the forum and helping us with investigations. The root cause of the issue has been identified and fix has been rolled out. The framework update will take a couple of days to reach most devices as and when any new app or updated ad-enabled app gets updated on the Xbox device.
Dev Mode only: The issue doesn't affect Dev mode and only Retail mode since Retail mode actually is the most secure and most strict environment and requires that all binaries involved are signed and certified. If anything is missing, Retail mode is the only one which will surface the issue in this fashion - not loading the libraries.
Fix and roll out process: You could reach out to the users who reported problems for your app and ask them to re-install your app. The other option that you (as a developer) have is to push an update to your app (only version change) and push it to your users. This will get the framework updated on the end user devices and speed up the fix roll out. Those developers who had taken off the ad control, please put it back and push the update for your apps.
Please feel free to reach out to us (msft-aia-help#microsoft.com) in case of any issues or queries regarding this topic. Thanks for the patience and sorry for the inconvenience caused during this period.
-Vivek.
Seems like the AdControl issue started around 9th Feb and is affecting several apps on Xbox One and is possibly due to a framework update to the libraries involved. Not sure why it isn't affecting Dev Mode as well.
I have got a update from our engineering team, this issue has been fixed. But you may need to uninstall and reinstall any of the affected apps in your XBOX, after that it should work fine.
Please let me the result after you reinstall all the affected apps in your XBOX.
Thank you.

Click Once in Windows 10 NotifyIcon not displaying

So using the following diagram:
You can see that the only time when anything breaks is when I use ClickOnce in Windows 10, however the notifications work perfectly fine if I run it directly from the exe. When I run it using ClickOnce using the console I can see the same methods get hit in the console but the notifications don't show up. I have tried to get this fixed for a very long time now with no avail.
The click once is deployed to a network share. The ClickOnce notifications work fine on Windows 8. I have absolutely no idea what could be causing this.
So got into discussion with someone I know at Microsoft and it looks like in the latest version (that he said should be released somewhere in November 2015) should contain the fix for this issue.
Waiting it out and hopefully the fix comes, if not I will contact him again and see how things are going as I would say this is a really bad problem.

WP App crashes after an update

I've got a small problem that im not quite sure how to solve, i perform regular updates to my windows phone apps in C#, the problem im having is sometimes when some people update the app it wont open for them and this is only a very few people. Even after removing and reinstalling the app it still won't open, i can't recreate this error myself ive tried, but the weird thing is the last time i updated and got a complaint i only changed one thing a url in a webbrowser which has no actual effect to the app and it caused this problem, any advice on what could cause it, maybe isolated storage if so how or advice on how to get an error for the app.

c# application working on development machine, fails on non-development machine

this problem has me baffled.
I'm writing an application which is supposed to take information from a form, pass it to a background worker which then a) writes the information to a local xml file and b) inserts the information into a remote MySQL database.
On my development machine, it seems to work flawlessly. The remote database is updated, the xml file is created if necessary and updated if it already exists. It's working.
Even if I exit out of the development environment and run the release build independantly of the IDE sandbox, the code works.
But, if I put it on another machine, the code fails and I dont understand why.
I'm currently using Visual Studio 2010 Professional on a 32 bit Windows 7 Ultimate machine.
At the moment, I'm finding that the application is stopping at a fairly specific point, which seems to be precisely where the background worker starts doing things like accessing the file system or accessing the remote database.
The project consists of a single exe file and a dll, which has a custom control I designed in it. The custom control is working fine, in that it shows what I want it to and returns the values I'm asking it to when I want it to, so it would seem that isn't to blame.
I initially thought I could be looking at a permissions problem, but running the application as administrator gets me the same response.
I've been writing using version 4 of the .NET framework, however I've just downgraded that to version 3.5 in the hopes that that may help. Both the non-development machines I've tried have been up to date - or have been brought up to date by me - prior to attempting to run the application.
I'm honestly baffled here. Any suggestions would be most welcome.
Alan
If your code fails, it most likely means there is some uncaught exception. What you should do is to log all uncaught exceptions (and probably some of the caught too) to a file, possibly using something like log4net.
I don't think we can help you beyond that.
I have written a live logging utility called Donsole for diagnosing the application in such conditions. On the developer workstation, it is very easy to diagnose using the feature-rich debugger of VS. The utility app. helps the developers exactly in this kind of scenarios where they don't have any idea what's happening inside. I recommend you download the latest build and try it for yourself. Explaining how to use this utility and how it works is beyond the scope of this answer, so I'd forward you to the codeplex page of the project.
http://donsole.codeplex.com/
This is how it looks.
Take a look at the event viewer of your operating system. Administrative Tools>Event Viewer>Windows Log>Application.

Categories