TypeInitializationException in WP7

Topics: Bugs
Aug 17, 2011 at 9:15 AM

Hi,

I'm getting a TypeInitializationException after upgrading my project to CM 1.2.
It seems to occur in the Action class in the last line of SetTargetCore function - Message.SetHandler(d, target)

The exeption does not have an internal exception and the message is:

Stack trace:

   at Caliburn.Micro.Action.SetTargetCore(DependencyPropertyChangedEventArgs e, DependencyObject d, Boolean setContext)
   at Caliburn.Micro.Action.OnTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Caliburn.Micro.Action.SetTarget(DependencyObject d, Object target)
   at Caliburn.Micro.ViewModelBinder.<.cctor>b__9(Object viewModel, DependencyObject view, Object context)
   at Caliburn.Micro.FrameAdapter.OnNavigated(Object sender, NavigationEventArgs e)
   at System.Windows.Navigation.NavigationService.RaiseNavigated(Object content, Uri uri, NavigationMode mode, Boolean isNavigationInitiator, PhoneApplicationPage existingContentPage, PhoneApplicationPage newContentPage)
   at System.Windows.Navigation.NavigationService.CompleteNavigation(DependencyObject content, NavigationMode mode)
   at System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result)
   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)

After that my app crashes.
I have no idea where to start looking.

Aug 17, 2011 at 4:20 PM

Is it possible for you to file an issue with a repro?

Aug 27, 2011 at 9:26 PM

Actually, I managed to find the problem.

Apparently, after upgrading both my own and CM projects to WP7.1, the CM projects were still reffering the old System.Windows.Interactivity assembly.
Making the CM assemblies refference the new  System.Windows.Interactivity assembly solved the problem.