LoadListingInformationAsync throws a FileNotFound exception - windows-runtime

I have a customer who is unable to do in-app purchasing from one of my Windows 8.1 Store apps.
Looking at the logs, I see that the call to load listing information:
await CurrentApp.LoadListingInformationAsync();
throws a FileNotFound exception
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)'
Any idea why this exception is being thrown?
We have less than 100 in-app purchasing items.

Can you reproduce this on your device? I would suggest to run it on the UI thread: Deployment.Current.Dispatcher.BeginInvoke(() => await CurrentApp.LoadListingInformationAsync());

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.

Gyrometer exception handling fails 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.

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;

Facebook sdk for windows phone LoginAsync method throws an Facebook.WebExceptionWrapper exception

I am making Windows Phone 8 application and it uses facebook login to identify users. When they first time log in they see facebook login dialog but next time when user starts application login happens on background. That works very well when phone is connected to internet but if i close network and try start application FacebookSessionClient.LoginAsync methdod returns my session normally and application continue it's normal flow. But suddenly i get unhandled exception on my App.cs class.
Here is my stack trace:
$exception {System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid. Check InnerException for exception details. ---> Facebook.WebExceptionWrapper: The remote server returned an error: NotFound. --->
System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at Facebook.OpenReadCompletedEventArgs.get_Result()
at Facebook.Client.FacebookSessionClient.<SendAnalytics>b__0(Object o, OpenReadCompletedEventArgs e)
at Facebook.HttpHelper.OnOpenReadCompleted(OpenReadCompletedEventArgs args)
at Facebook.HttpHelper.ResponseCallback(IAsyncResult asyncResult, Object userToken)
at Facebook.HttpHelper.<>c__DisplayClass2.<OpenReadAsync>b__0(IAsyncResult ar)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass1d.<InvokeGetResponseCallback>b__1b(Object state2)} System.Exception {System.Reflection.TargetInvocationException
I have tried try catch block many places in my code but i't doesn't stop there. Also when it breaks on app.cs it show that error comes from another thread.
This is how i call facebook login if user is logged before
FacebookSession facebookSession = await App.FacebookSessionClient.LoginAsync();
And it returns immediately and gives current session. But about ten seconds later app crashes. Can anyone give me a hint how i can handle that error correctly or how i can prevent that? I use 0.8 facebook sdk version.
Check this question: Facebook Wrap Exception Wrapper
This is the same bug already fixed in GitHub repo but not yet available via NuGet. The solution to your problem is to build Facebook.Client from source instead of downloading it with NuGet.