InvalidProgramException

Jul 10, 2011 at 11:07 PM
Edited Jul 10, 2011 at 11:08 PM

I followed the instructions to add the control to my app. On the app launch, the InvalidProgramException is thrown. Any idea what the reason is? I receive the same error even when running the AdRotatorExample project.

Coordinator
Jul 10, 2011 at 11:19 PM

Hi! Could you copy the details of the exception (Message, stack trace, possible InnerException)? Since I can't reproduce that and have never seen it it's hard to guess what might cause it! Also, are you building for 7.0 or 7.1?

Jul 10, 2011 at 11:26 PM
Edited Jul 10, 2011 at 11:26 PM

I am building against 7.0.

Here is the exception:

"System.InvalidProgramException: InvalidProgramException\r\n   at System.RuntimeType.GetConstructorImplInternal(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers, Boolean verifyAccess)\r\n   at System.RuntimeType.GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)\r\n   at System.Type.GetConstructor(BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)\r\n   at System.Type.GetConstructor(Type[] types)\r\n   at MS.Internal.TypeProxy.GetCreateObjectDelegate(UInt32 customTypeId)\r\n   at MS.Internal.TypeProxy.CreateInstance(UInt32 customTypeId)\r\n   at MS.Internal.FrameworkCallbacks.CreateKnownObject(IntPtr nativeRootPeer, UInt32 customTypeId, String initializationString, IntPtr& nativePeer, UInt32 isCreatedByParser)\r\n   at MS.Internal.XcpImports.Application_LoadComponentNative(IntPtr pContext, IntPtr pComponent, UInt32 cUriStringLength, String uriString, UInt32 cXamlStrLength, Byte* pXamlStr)\r\n   at MS.Internal.XcpImports.Application_LoadComponent(INativeCoreTypeWrapper componentAsDO, String resourceLocator, UnmanagedMemoryStream stream, UInt32 numBytesToRead)\r\n   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)\r\n   at AdRotatorExample.MainPage.InitializeComponent()\r\n   at AdRotatorExample.MainPage..ctor()\r\n   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)\r\n   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)\r\n   at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)\r\n   at System.Activator.CreateInstance(Type type)\r\n   at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)\r\n   at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)\r\n   at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)\r\n   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)\r\n   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)\r\n   at System.Delegate.DynamicInvokeOne(Object[] args)\r\n   at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)\r\n   at System.Delegate.DynamicInvoke(Object[] args)\r\n   at System.Windows.Threading.DispatcherOperation.Invoke()\r\n   at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)\r\n   at System.Windows.Threading.Dispatcher.OnInvoke(Object context)\r\n   at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)\r\n   at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)\r\n   at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)\r\n"

Coordinator
Jul 10, 2011 at 11:27 PM

that's the stack trace. Any chance you could share the Message please? :)

Coordinator
Jul 10, 2011 at 11:28 PM

And also, is the InnerException null?

Jul 10, 2011 at 11:32 PM

The exception it caught by Application_UnhandledException method.

Message: "InvalidProgramException"

InnerException: Could not evaluate expression. 

Coordinator
Jul 10, 2011 at 11:49 PM

Thanks. Assuming the InnerExcepion is null, I've no idea why this could be happening - seems like some binding would be failing in the MainPage of AdRotator, but it doesn't seem to have any other references to the control itself.

If you want to get to the bottom of it, you could download the source, code, open the solution, run it and see if the same issue is present. If so, there you will at least see line numbers, but from this stack trace I'm clueless.

Jul 11, 2011 at 1:39 AM

I have downloaded the source and rebuilt it. The AdRotatorExample executed without any problems. The wp7adr-0.6.zip is missing admonb, adduplex, and other assemblies. Once I have copied those assemblies to the bin folder and ran the project again, it all started working. I copied the assemblies to my apps folder and it also worked fine.

I would recommend verifying the release assemblies provided in the download on the main page. I think something is wrong with them.

Thanks for your help and prompt response.

May 1, 2012 at 10:34 PM

 

Erro ???????????

Foto

Coordinator
Jun 14, 2012 at 1:55 PM
slobo80 wrote:

I have downloaded the source and rebuilt it. The AdRotatorExample executed without any problems. The wp7adr-0.6.zip is missing admonb, adduplex, and other assemblies. Once I have copied those assemblies to the bin folder and ran the project again, it all started working. I copied the assemblies to my apps folder and it also worked fine.

I would recommend verifying the release assemblies provided in the download on the main page. I think something is wrong with them.

Thanks for your help and prompt response.

A few queries on the above, you mention the "wp7adr-0.6.zip" which implies your not using the latest version which is 1.2.

Also as the current implementation instructions state, you should reference the Ad Provider assemblies provided with the specific release (in case ad providers update their controls with breaking changes).  You can do as you suggest and copy the dll's to your bin folder but this isn't idea as next time you "rebuild" the project you could loose them.

Also one other point, the example apps USE the dll's provided with the package as you'll notice the project does not have a bin / obj folder.

If your still having issue please copy in the XAML your using to declare the ad control on the page and/ or a sample project copying in the specific implementation you have done to ease investigation of this issue.

 

In the past I have found that such an error is only caused by:

  • No referencing / including the Ad provider dll's in your project (AdRotator cannot initialise as it does not have the DLL's available in the project instantiating it)
  • Not including all the AdProvider DLL's for all the providers you have configured
  • Incorrect XAML parameters (we can only validate parameters so far)
  • invalid or incorrect configuration XML (either remote / local) - we do our best to handle this situation but it's never 100% perfect.

 

We've always aimed to make this control as easy to implement as possible and focus on the management elements to reduce it's impact on builds so it can be updated without having to update the project.

 

Let us know how you get on

Jun 19, 2012 at 6:12 PM
Edited Jul 10, 2013 at 12:55 AM
Hi all, The problem is caused by version: (5.2.0.0) Microsoft.Advertising.Mobile (5.2.0.0) Microsoft.Advertising.Mobile.UI Please step by step to fix this:
  1. Remove references to Microsoft.Advertising.Mobile and Microsoft.Advertising.Mobile.UI in your project
  2. Download DLL Microsoft.Advertising.Mobile and Microsoft.Advertising.Mobile.UI version 6.1.0.0 at http://www.mediafire.com/?qk43mifn31dua2d or Ad Rotator lastest version( find in folder v1\AdRotator\Bin\Release)
  3. Add references Microsoft.Advertising.Mobile and Microsoft.Advertising.Mobile.UI (version 6.1.0.0)
Hope this help!

If you have problems please send email for me (tano8753@gmail.com).