Gyrometer exception handling fails windows phone 8 - windows-phone-8

I was trying to access the Gyrometer capabilities from Windows Phone 8 but a First Chance Exception keeps poping when I try to get a handle to the sensor via Gyrometer::GetDefault(), that I cannot catch it in a "try catch" block.
The error message is:
ERROR SensorOpenByInterface: Primary sensor not found.
The msdn clearly states that the default behavior is to return a null pointer if the sensor doesn't exist. I must mention that the manifest has the sensors capability enabled and the app runs on Windows Phone 8 HTC8x Release build.
try{
gyrometer = Gyrometer::GetDefault();
}
catch(Exception ^Exc){...}.
It fails right after the GetDefault, and can't even handle handle the exception.

Related

ToastNotifier.GetScheduledToastNotifications() throws "Element not found" (Exception from HRESULT: 0x80070490)

I've noticed in my telemetry data that the following code sometimes results in an exception "System.Exception: Element not found. (Exception from HRESULT: 0x80070490)"
var notifier = ToastNotificationManager.CreateToastNotifier();
var notifications = notifier.GetScheduledToastNotifications();
The code is run inside a Windows Phone 8.1 (WinPRT) application on a background thread and the exception is thrown quite sparsely.
Any ideas what might be causing this or additional information I can provide?
I had the same problem.
It took a long time to figure out, but it's a really easy fix :
"The exception is because you need to provide an applicationId in CreateToastNotifier()"
( Windows 10: Showing a toast Notification )
Maybe late to the party, but in my case it was caused by the fact that I was removing some scheduled toasts in another thread at that moment.

Azure Mobile Services authentication not working with Windows Phone 8.1 Universal app

I'm adding Azure Mobile Services authentication to a Universal Windows project. It's all set up and working properly on the server and in the Windows Store version of the app, however I can't get it to work with the Windows Phone 8.1 version of the app. I actually have two different apps that I've been working on with the same problem, so I created a test app based strictly on the steps outlined in this article. The sample app has one button on the UI that will attempt authenticate the user with Twitter when pressed.
The flow that I am seeing from the UI is:
Press the button
Screen goes black for a moment
Screen displays "Resuming..." with a spinner
InvalidOperationException gets caught
The exception details:
System.InvalidOperationException was caught
HResult=-2146233079
Message=Authentication was cancelled by the user.
Source=mscorlib
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceAuthentication.<LoginAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at MobileAuthTest.MainPage.<AuthenticateAsync>d__3.MoveNext()
InnerException:
The code I am using is copied almost verbatim from the article, but I'll paste it here too:
private async void Button_Click(object sender, RoutedEventArgs e)
{
await this.AuthenticateAsync();
}
// Define a method that performs the authentication process
// using a Twitter sign-in.
private async Task AuthenticateAsync()
{
while (user == null)
{
string message;
try
{
// Change 'MobileService' to the name of your MobileServiceClient instance.
// Sign-in using Twitter authentication.
user = await App.mobileService
.LoginAsync(MobileServiceAuthenticationProvider.Twitter);
message =
string.Format("You are now signed in - {0}", user.UserId);
}
catch (InvalidOperationException)
{
message = "You must log in. Login Required";
}
var dialog = new MessageDialog(message);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
}
And this override is in App.xaml.cs:
protected override void OnActivated(IActivatedEventArgs args)
{
// Windows Phone 8.1 requires you to handle the respose from the WebAuthenticationBroker.
#if WINDOWS_PHONE_APP
if (args.Kind == ActivationKind.WebAuthenticationBrokerContinuation)
{
// Completes the sign-in process started by LoginAsync.
// Change 'MobileService' to the name of your MobileServiceClient instance.
mobileService.LoginComplete(args as WebAuthenticationBrokerContinuationEventArgs);
}
#endif
base.OnActivated(args);
}
My testing is all on a real Windows Phone 8.1 device (Nokia 920 with 8.1 update).
It's also worth pointing out that the project I'm currently trying to get this to work in is also using Xamarin.Forms for Android, iOS and Windows Phone (I wanted a comparison between Xamarin.Forms for Windows Phone and Universal apps for Windows Phone). All of the apps work, EXCEPT for the two Windows Phone apps. The Xamarin.Forms Windows Phone app is a Windows Phone Silverlight 8.1 app which acts the same as described above for the Universal WP, but fails with the error, "Authentication failed with HTTP response code 0."
I've searched around and haven't found any other cases of people encountering the same issue I am. Is there something I need to do that is so simple nobody feels the need to say it in writing?
Well, it turns out that the issue I am seeing may just be my device. I sent the sample app to another dev for testing and he had no issues. I also was able to successfully log in with both the sample app and the real app on the simulator. That isn't exactly a thorough test sample, but it's enough for me to stop banging my head on this desk.

Error 0X800455BC when creating a SpeechRecognizer object on Windows Phone 8.0?

My Lumia 820 is running Windows Phone 8.0. My Lumia 520 is running Windows Phone 8.1 developer preview. Speech reco works fine on the Lumia 520, but with the 820 I get a System.Exception with an HRESULT code of 0x800455BC. I did some research and that error is supposed to be localization related. It happens when the language your phone is set to is not supported by the speech recognizer:
Exception HRESULT: 0x800455BC in speech recongnition in Windows phone 8
Except I am not getting the same call stack as what that page shows. Also, the solution offered on that page says I should set my recognizer to the desired language explicitly. But that's a problem since I get the error when I create the recognizer. Since I can't create it, I can't set the language. Other people get the error when they try to do a speech recognition session.
Note, I definitely have enabled speech recognition via the phone settings, even allowing it when the phone is locked. Have any of you seen this and know what to do about it? I get the error right when I try to construct the SpeechRecognizer object:
// Create the recognition engine.
this.SpeechRecognizerObj = new SpeechRecognizer();

Generate Windows Phone 8 Crash Dumps

Does anyone know of a way that I can configure a Windows Phone 8 to generate Crash Dumps for applications that are being developed?
I know that we can get access to dumps that are sent to the MS app store, but I need a dump of an application that is still in development.
Thanks
In "App.xaml.cs" class you will find a method called "Application_UnhandledException". This method is launched every time that your app crashes due an unhandled exception. In the event args you will find the error message, stack trace, etc...
Add your logic here to dump the crash (for example, send an email, or store the log in a database, etc...)
BTW, if the exception is recoverable, you can handle the error and don't close the app setting the Handled variable to true:
// Recover from the error
e.Handled = true;

Silverlight Exceptions on Server [duplicate]

I recently encountered a strange thing. On some of my company's servers when an exception message is printed out (yes, bad, I know. It's for debugging), the actual message isn't displayed. Instead it displays the key for an external string resource and says that "Debugging resource strings are unavailable"
After some research I've come up with the following:
In release mode, Silverlight does not package the xap with the dlls containing the actual error messages in order to save space.
I've found workarounds for OLD versions, but nothing for 4. It seems like there are Developer versions of the SL 2 and 3 runtime which will resolve the errors automatically, but I cannot find one for SL 4.
So my question is this:
What the heck do I need to do to my SL 4 app / computer to let me see the full, detailed errors when it's in release mode?
You can download the developer runtime (which contains the full exception strings) from the GetStarted page - http://www.silverlight.net/getstarted/ - search for "Developer Runtimes for Windows and OSX", it's near the bottom of the page.
Though it is too late to reply, it may help somebody else. We have a web application using Silverlight 4, installed in various test environments. This web application consumes more than one WCF services. All but one of the test environment sites consistently failed with message "Debugging Resource strings are unavailable". Agreeably the real exception was swallowed. Being a Silverlight application, there was no logging, and it always appeared that there was something failing in the Silverlight component. I connected the application in my development environment to that particular test environment, and found out that the problem was in fact in one of the WCF services. I fixed the problem at the service end and the SL component stopped having this problem.
Why was the WCF failing?
The WCF service had the following code in the constructor:
public MyService()
{
//Create an instance of Data Lookup service asycnchronously.
if (_dataLookupSrvc == null)
{
try
{
System.Threading.Tasks.Task.Factory.StartNew(() => _dataLookupSrvc = new LookupDataService.LookupDataService());
}
catch (Exception ex)
{
_log.Error<Exception>(ex);
}
}
}
Somebody moved the underlying LookupDataService.dll from the service folder causing the constructor to fail, but not right away. As the LookupDataService instance was created in anonymous method, the exception logging in this method never took place. Once the LookupDataService.dll was dropped in the service folder, the "Debugging Resource strings are unavailable" message went away.
It was a fun wild goose chase!
Have you already checked the event viewer on the machine where the application crashed? Start->Run. eventvwr