advertising Ad control disappear and Throws Exception in windows phone 7 - windows-phone-7

i am getting exception from Adcontrol as
"A first chance exception of type 'Microsoft.Advertising.Mobile.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll".
my ad control is disappear and throw this kind of exception so what should i do for this kind of problem please Tell me if anybody known

The exception is probably thrown because there isn't any ad served.
Your app will only receive ads if they are available. If it is not the case, the control disappears. You get that exception while you are debugging the app, but when deployed and executed in a real device, it doesn't make the app break.
Anyway, just to make sure that this is what causes the exception you can subscribe to the ErrorOccurred event of the ad control, and check what happens:
private void AdControl_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Ad Error : ({0}) {1}", e.ErrorCode, e.Error);
}

Related

How to make Web API Stop working on occurance of specific exception

In some scenarios I am getting exceptions in Startup.cs file.
So I want to catch that exceptions and do not show specific errors to Users.
I tried this:
I catch exceptions and throw as Custom exceptions, even though it shows stack-trace and all things into browser.
And if I left catch block empty then Web API still remains available (working).
I want to pause or stop my service for this scenarios.
Please help me.
I've No rights to comment so I'm going to write my answer here
as far as I understood your question why don't you use Application Error in global.asax file
Just like this
private void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex is HttpAntiForgeryException)
{
Response.Clear();
Server.ClearError();
Response.Redirect("/error/errorPage", true);
}
}
Hope I understood your question

How to catch System.InvalidOperationException: Connection was disconnected before invocation result was received

I´m getting this error exactly how the exception message says.
If a mobile client loses connection before the proxy.Invoke() result arrive, the exception is raised. That´s ok, but I need to catch this to avoid an app crash.
I try/catch all the proxy.Invoke() and proxy.Invoke<T>() calls, with no effect though.
How can I catch that exception?
Note: I´m using SignalR client 2.2.0 in a Xamarin client (PCL)
If you are calling your proxy.Invoke() without await proxy.Invoke() then the exception won't bubble up from the Invoke task to your executing code.
I've had to deal with this error before (with Xamarin in a PCL), and simply executing my Invoke like such worked for me:
try
{
await hubProxy.Invoke("SomeMethod", args);
}
catch (InvalidOperationException ex)
{
// Do what you need to with the exception
}
There is also a conversation about it here on the SignalR GitHub.

Authentication failed with Azure Active Directory in Windows Phone

I am follow the window phone authentication tutorial with Add authentication to your Mobile Services app. And I choose using Azure Active Directory way to make authentication. But the question is: it always fails and shows The remote procedure call failed. (Exception from HRESULT: 0x800706BE) at the following code
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
await Authenticate();//here throws System.Exception in mscorlib.ni.dll
await RefreshMissionTable();
}
And I make sure there is nothing wrong in my Azure setting. The weird thing is that when I choose windows phone universal app sample, and do the same procedure again, it can work in the windows 8.1 emulator! But still can't work in the windows phone 8.1 emulator .
And the break point stays here
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
}
}
}
this might be related to a known problem with the WebAuthenticationBroker on Windows Phone 8.1: it cannot be invoked until the full UX of the app has been loaded. Please take a look to this thread for a description of the issue and proposed workarounds: https://social.msdn.microsoft.com/Forums/vstudio/en-US/95c6569e-2fa2-43c8-af71-939e006a9b27/mobile-services-loginasync-remote-procedure-call-failed-hresult-0x800706be?forum=azuremobile
HTH
V.

How to intercept and handle all exception of Windows phone Application?

We did't have any Test team support for our Product Development.
so.
we need intercept and handle all Exception for improve User experience.
is There have any Soluction in windows phone Application?
as Fllow in app.xaml.cs file. we found :
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is QuitException)
return;
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
}
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
}
}
Yes, this should catch all the exceptions that you missed in your app. Considering that you obviously are not catching many exception somewhere else and are looking for a simple solution, this event handler might work, but I seriously don't recommend it.
This event handler catches the exceptions and then should crash/quit your app. If you handled your exceptions only here, this would lead to a huge crash count. Sometimes exceptions happen, but the app can continue working normally. That's why I recommend that you handle them as they happen in your code, and not here. That way you have a full control of how your app continues and if it continues at all, and reduce the number of "unhandled exceptions" and app crashes.
Put your code in Try-Catch Block. I was also facing such problem, but then handled by Exception Handling Method.
try
{
// your code
}
catch (Exception ex)
{
throw (ex);
}

what is the cause of 'System.IO.IsolatedStorage.IsolatedStorageException'?

Exceptions:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll
public static IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
private void GetScoreData()
{
if (settings.Contains(dataItem2.Name))
{
this.textBlock2.Text = settings[dataItem2.Name].ToString();
}
else
{
settings.Add(dataItem2.Name, "N/A");
this.textBlock2.Text = "N/A";
}
settings.Save();
}
now in the other page
i am updating its value by doing this
ScorePage.settings["MyKey"] = moves.ToString();
so everytime i restart my emulator and run my project this exception comes.
any reason why?
The isolated storage in the emulator is not persisted after you close it.
Reference: Windows Phone Emulator: (see features)
Isolated storage is available while the emulator is running. Data in isolated storage does not persist after the emulator closes. This includes files stored in a local database, as these files reside in isolated storage.
I suggest you to use site settings over application settings.
One more thing, dont worry the windows phone is persistent.(only the emulator is not!)
After restarting the emulator (or reinstallign the app), the contents on IsolatedStorage will be deleted. If you're trying to update a setting, first check that the key exists.
Showing the line where the exception occurs and the exact text of the exception will also help with identifying the issue.

Resources