AdMob crash

How and where should I catch and handle this error:

A first chance exception of type ‘System.NullReferenceException’ occurred in GoogleAds.DLL

An exception of type ‘System.NullReferenceException’ occurred in GoogleAds.DLL but was not handled in user code

Additional information: Object reference not set to an instance of an object.

The thread 0x1e8 has exited with code 259 (0x103).

An unhandled exception of type ‘System.Reflection.TargetInvocationException’ occurred in System.Windows.ni.dll

Additional information: Exception has been thrown by the target of an invocation.

This is likely a bug in your C# code.  If you run your app in the Visual Studio debugger, it should show you where in your code the null exception is coming from.  You can also have a look at the stack trace in Visual Studio to pinpoint it as well.  Odds are you are passing null to Google ad library.

I also recommend that you run Google’s ad sample project as is.  Have a look at how they’ve coded it in their sample project to give yourself an idea on how to integrate it into your project.  It’s actually pretty simple to integrate.

Thank you Joshua for your reply.

Actually, the ads are working (banner and interstitial) and this happened only once for now.

From the error it looks like the problem was in GoogleAds.dll.

What I am interested is can I prevent the game crash in such a scenario or is this out of my reach?

I haven’t heard of it crashing in other developers’ apps.  It *might* be a bug in Google’s library, but if it were, then I think other WP8 developers would have abandoned it then and use a more reliable ad library.  That’s why I’m thinking that you might want to double check the stack trace next time the exception occurs to see if there is anything in your code triggering it.

This is likely a bug in your C# code.  If you run your app in the Visual Studio debugger, it should show you where in your code the null exception is coming from.  You can also have a look at the stack trace in Visual Studio to pinpoint it as well.  Odds are you are passing null to Google ad library.

I also recommend that you run Google’s ad sample project as is.  Have a look at how they’ve coded it in their sample project to give yourself an idea on how to integrate it into your project.  It’s actually pretty simple to integrate.

Thank you Joshua for your reply.

Actually, the ads are working (banner and interstitial) and this happened only once for now.

From the error it looks like the problem was in GoogleAds.dll.

What I am interested is can I prevent the game crash in such a scenario or is this out of my reach?

I haven’t heard of it crashing in other developers’ apps.  It *might* be a bug in Google’s library, but if it were, then I think other WP8 developers would have abandoned it then and use a more reliable ad library.  That’s why I’m thinking that you might want to double check the stack trace next time the exception occurs to see if there is anything in your code triggering it.