Unhandled exception in designer

Apr 2, 2012 at 5:59 AM

After following the directions here: http://xna-uk.net/blogs/darkgenesis/archive/2012/02/13/would-you-like-ads-with-that-intro-to-adrotator-for-wp7.aspx

 

I get a crash of the xaml designer in Visual Studio 2010 Express for WP running on Win8CP.

 

"System.NullReferenceExceptionObject reference not set to an instance of an object.   at AdRotator.AdRotatorControl.Invalidate(Boolean selectNextAdType)   at AdRotator.AdRotatorControl.AdRotatorControl_Loaded(Object sender, RoutedEventArgs e)   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
 Microsoft.Windows.Design.Platform.InvalidDesignerUpdateExceptionAn unhandled exception was encountered while trying to render the current silverlight project on the design surface. To diagnose this failure, please try to run the project in a regular browser using the silverlight developer runtime."

Running on actual device compiles, but fails to show any ads (just black box).

Any ideas?

Apr 15, 2012 at 12:52 PM

We've not tested the toolkit running on the Win 8CP, so it is a likely culprit.

I would suggest starting a new project and try adding the control to the package either as a DLL or as a project and see if you can replicate it.

I did have one issue similar to this a while back but it cleared it'self up after a clean rebuild.

May 6, 2012 at 6:19 PM

I had the same issue and after comparing my test project with the sample project I found that my defaultAdSettings.xml had the Build Action property to Content. After changing to Resource like the sample project and rebuild the solution everything is ok.

I hope this will help you.

Regards,

May 6, 2012 at 11:23 PM

Issue persists on fresh Win7 Pro. App is in Marketplace, and correctly showing ads so not much of a problem - just means I have to work on my xaml design skills!

 

@murbaheu - I tried this, but now get a different error: 

System.InvalidOperationException[NoElements]Arguments: Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.1.10111.0&File=System.Core.dll&Key=NoElements   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)   at AdRotator.AdRotatorControl.Invalidate(Boolean selectNextAdType)   at AdRotator.AdRotatorControl.AdRotatorControl_Loaded(Object sender, RoutedEventArgs e)   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

May 8, 2012 at 3:14 PM
murbaheu wrote:

I had the same issue and after comparing my test project with the sample project I found that my defaultAdSettings.xml had the Build Action property to Content. After changing to Resource like the sample project and rebuild the solution everything is ok.

I hope this will help you.

Regards,

That is correct, the defaultAdSettings.XML file does have to be set to "Content" for it to work properly.

In the latest update however you will be able to skip it if you wish as we fixed the issue with AdRotator not saving the downloaded config file.  From now on the "defaultAdSettings" file will only be used until a network connection is available, from then on it will use the most current from the web.

May 8, 2012 at 3:17 PM
Edited May 8, 2012 at 3:17 PM

fillupt

If your still having issue, then I suggest you download the source and hook it up to your project instead of referencing the release DLL.  If you then attach visual studio to Blend when you open the page with the error on it, it will then show you the specific piece of code causing the issue, then we can take steps to resolve it if ness.

See this article for how to do it - http://blogs.msdn.com/b/expression/archive/2008/06/19/debugging-design-time-exceptions.aspx

*Note, this only works with Pro visual studio or above i'm afraid.  It's not available in the Free tools.

May 12, 2012 at 4:18 PM
Edited May 12, 2012 at 4:18 PM

I can confirm this issue running on a Win7 64bit with VS2010 Ultimate

 

Just installed v1.0 and as soon as I paste the xaml to get the ad component, the designer fails with:

System.NullReferenceException
Object reference not set to an instance of an object.
   at AdRotator.AdRotatorControl.Invalidate(Boolean selectNextAdType)
   at AdRotator.AdRotatorControl.AdRotatorControl_Loaded(Object sender, RoutedEventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)

This happens in both my project and the sample project.

I cannot build/start the app without getting a nullreferenceexception in mainpage.g.cs when it's loading the xaml page.

May 13, 2012 at 8:14 PM

Retry with the new point release and see if this solves the problem, it was most likely down to PubCenter.

May 16, 2012 at 2:51 PM

I've gotten to the bottom of why AdRotator was causing the designer to crash, specifically it was down to the control trying to serve ads while in the designer :D, Blend did not like this even though everything is marshalled correctly.

I've added design time support to the latest release and will publish shortly

Nov 25, 2013 at 3:27 PM
I'm seeing this same problem, but this time when it happens under Visual Studio 2012 and Blend while creating a Windows Phone 8 application. No exception is shown when I use those tools with a Windows Phone 7 application.
Nov 25, 2013 at 4:16 PM
So long as your app/game runs I would ignore this error for now. We added code to prevent the Ads rendering during design time but something has changed, we are looking in to it.
Nov 25, 2013 at 4:24 PM
It's not running, I've updated other threads about it. But it's good to know that it's not a symptom of another problem, thanks.
Nov 25, 2013 at 4:32 PM
Ahh right, I commented in your other thread which seems to be a referencing issue.