FileNotFoundException loading Microsoft Advertising DLL

May 4, 2012 at 5:42 AM

I am encountering a problem in my Silverlight app. 

  • I downloaded the binary and set it up according to the "Would you like Ads with that!" tutorial on http://xna-uk.net.
  • I added the AdRotator control to my MainPage.xaml via multiple different means: manually and Blend, but not Designer.  The control doesn't show up as an option in Designer.
  • When I double-click on MainPage.xaml, I get the following error in the Designer pane:

An Unhandled Exception has occurred

Click here to reload the designer

Details:

System.IO.FileNotFoundException
Could not load file or assembly 'Microsoft.Advertising.Mobile.UI, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
   at AdRotator.AdRotatorControl.RemoveEventHandlersFromAdControl()
   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)

 
Microsoft.Windows.Design.Platform.InvalidDesignerUpdateException
An 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.

The Version number in this message caught my eye.  It references 5.2.0.0 and I have 6.1.0.0 installed and referenced in the project.  I did note that the value of the PublicKeyToken in my DLL matches the one given in the error message.

 

I downloaded the AdRotator source code and ran the example.  That works fine.  However, I think the difference there is that the AdRotator control is a project in the solution, and in my app it's just the DLL(s).

 

When I try to run the app despite the error on MainPage.xaml, I get an exception in MainPage.g.i.cs InitializeComponent() on this line:
System.Windows.Application.LoadComponent(.....MainPage.xaml", System.UriKind.Relative));
Here's the exception dump:

System.Windows.Markup.XamlParseException occurred
  Message=Unknown parser error: Scanner 2148474880. [Line: 64 Position: 17]
  LineNumber=64
  LinePosition=17
  StackTrace:
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at Deliverator_OnePage.MainPage.InitializeComponent()
       at Deliverator_OnePage.MainPage..ctor()
       at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
       at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
       at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)
       at System.Activator.CreateInstance(Type type)
       at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)
       at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)
       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)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at System.Delegate.DynamicInvokeOne(Object[] args)
       at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
       at System.Delegate.DynamicInvoke(Object[] args)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
       at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
       at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
       at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
       at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
  InnerException: System.InvalidProgramException
       Message=InvalidProgramException
       StackTrace:
            at System.RuntimeType.GetMemberMethod(String name, BindingFlags invokeAttr, CallingConventions callConv, Int32 argCnt)
            at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
            at System.Type.GetMethod(String name, BindingFlags bindingAttr)
            at MS.Internal.ManagedTypeInfoProviderRPInvokes.LookupProperty_End(PropertyInfo propInfo, EventInfo ei, Type type, String name)
            at MS.Internal.ManagedTypeInfoProviderRPInvokes.ResolvePropertyName(XamlTypeToken sTypeToken, String inPropertyName, XamlPropertyToken& outProperty, XamlTypeToken& outPropertyTypeToken)
            at MS.Internal.XcpImports.Application_LoadComponentNative(IntPtr pContext, IntPtr pComponent, UInt32 cUriStringLength, String uriString, UInt32 cXamlStrLength, Byte* pXamlStr, UInt32 cAssemblyStrLength, String assemblyStr)
            at MS.Internal.XcpImports.Application_LoadComponent(IManagedPeerBase componentAsDO, String resourceLocator, UnmanagedMemoryStream stream, UInt32 numBytesToRead, String assemblyString)
            at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
            at Deliverator_OnePage.MainPage.InitializeComponent()
            at Deliverator_OnePage.MainPage..ctor()
            at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
            at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
            at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)
            at System.Activator.CreateInstance(Type type)
            at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)
            at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)
            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)
            at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
            at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
            at System.Delegate.DynamicInvokeOne(Object[] args)
            at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
            at System.Delegate.DynamicInvoke(Object[] args)
            at System.Windows.Threading.DispatcherOperation.Invoke()
            at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
            at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
            at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
            at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
            at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

Thanks in advance for any insight you can provide.

Dave

{"Unknown parser error: Scanner 2148474880. [Line: 64 Position: 17]"}System
May 4, 2012 at 10:26 AM

Simple answer to this which you've already noted.

Microsoft recently updated their pubcenter control and the current release of AdRotator is coded against the initial release.  They introduced some breaking changes and refactored some of the references (mostly removing duplication between the XNA and Silverlight libraies.

To work around this either download the source for V1 or wait about 1 week for the point release to come out (i've already patched this issue in the current version of source but i've got a few more things to add before releasing)

 

Hope this helps.

May 5, 2012 at 4:08 AM

Great. Thanks! 

I may try my hand with the source, but since the point release is only a week away, I may just wait.  The example works for me, so I can use that to tune my settings file.

 

Thanks for the help.

Dave