Crash when compiling via build machines

Topics: Bugs
Sep 24, 2013 at 7:43 PM
We've been using CM at our company for a few months now to do some basic view / view model binding, and have just recently expanded our use of it by adding ContentControls to our window and binding them to a property on the window's view model that contains the view model for the ContentControl. Everything works just fine in our debuggers when we compile in both Debug and Release mode in VS2010. However, when we run a build that's compiled by our build machines, we see the exception shown below (with 3 inner exceptions below it).

When we replace the app executable compiled by our build machine with the app executable compiled by our VS2010 debugger in Release mode, everything works and no exception is thrown. Therefore, the problem doesn't seem to be caused by a missing DLL or other dependency, and it actually looks like the executable is being compiled differently by the build machine.

Why would CM behave differently when built via a build machine than when built via a VS2010 debugger? We're currently investigating but I'm really hoping to get some insight here to help point us in the right direction.

Message: Exception has been thrown by the target of an invocation. Stack: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
[1580] at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
[1580] at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[1580] at Caliburn.Micro.ActionMessage.<.cctor>b__d(ActionExecutionContext context)
[1580] at Caliburn.Micro.ActionMessage.Invoke(Object eventArgs)
[1580] at System.Windows.Interactivity.TriggerBase.InvokeActions(Object parameter)
[1580] at System.Windows.Interactivity.EventTriggerBase.OnEvent(EventArgs eventArgs)
[1580] at System.Windows.Interactivity.EventTriggerBase.OnEventImpl(Object sender, EventArgs eventArgs)
[1580] at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
[1580] at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
[1580] at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
[1580] at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
[1580] at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
[1580] at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
[1580] at MS.Internal.LoadedOrUnloadedOperation.DoWork()
[1580] at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
[1580] at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
[1580] at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
[1580] at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
[1580] at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
[1580] at System.Windows.Interop.HwndTarget.OnResize()
[1580] at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
[1580] at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
[1580] at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
[1580] at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
[1580] at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
[1580] at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
[1580] IDVault.exe Error: 0 :

[1580] UIThread_ThreadException Inner 0 message: Exception has been thrown by the target of an invocation.Inner 0 stack: at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
[1580] at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
[1580] at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
[1580] at System.Activator.CreateInstance(Type type, Boolean nonPublic)
[1580] at System.Activator.CreateInstance(Type type)
[1580] at Caliburn.Micro.ViewLocator.<.cctor>b__2(Type viewType)
[1580] at Caliburn.Micro.ViewLocator.<.cctor>b__d(Type modelType, DependencyObject displayLocation, Object context)
[1580] at Caliburn.Micro.ViewLocator.<.cctor>b__e(Object model, DependencyObject displayLocation, Object context)
[1580] at Caliburn.Micro.View.OnModelChanged(DependencyObject targetLocation, DependencyPropertyChangedEventArgs args)
[1580] at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
[1580] at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
[1580] at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
[1580] at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
[1580] at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
[1580] at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
[1580] at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
[1580] at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
[1580] at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
[1580] at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
[1580] at MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)
[1580] at MS.Internal.Data.PropertyPathWorker.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)
[1580] at System.Windows.WeakEventManager.ListenerList1.DeliverEvent(Object sender, EventArgs e, Type managerType)
[1580] at System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)
[1580] at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
[1580] at Caliburn.Micro.PropertyChangedBase.OnPropertyChanged(PropertyChangedEventArgs e)
[1580] at Caliburn.Micro.PropertyChangedBase.<>c__DisplayClass4.<NotifyOfPropertyChange>b__2()
[1580] at Caliburn.Micro.Execute.<>c__DisplayClass1.<InitializeWithDispatcher>b__0(Action action)
[1580] at Caliburn.Micro.Execute.OnUIThread(Action action)
[1580] at Caliburn.Micro.PropertyChangedBase.NotifyOfPropertyChange(String propertyName)
[1580] at Caliburn.Micro.PropertyChangedBase.NotifyOfPropertyChange[TProperty](Expression
1 property)
[1580] at GuardId.Dashboard.DashboardViewModel.set_CreditCardManagerViewModel(CreditCardManagerViewModel value)
[1580] at GuardId.Dashboard.DashboardViewModel.Window_Loaded()
[1580] IDVault.exe Error: 0 :

[1580] UIThread_ThreadException Inner 1 message: The method or operation is not implemented.Inner 1 stack: at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
[1580] at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
[1580] at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
[1580] at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
[1580] at GuardId.PersonalInfoControls.CreditCardManagerView.InitializeComponent()
[1580] at GuardId.PersonalInfoControls.CreditCardManagerView..ctor()
[1580] IDVault.exe Error: 0 :

[1580] UIThread_ThreadException Inner 2 message: The method or operation is not implemented.Inner 2 stack: at System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlType(BamlType bamlType, Int16 typeId)
[1580] at System.Windows.Baml2006.Baml2006SchemaContext.GetXamlType(Int16 typeId)
[1580] at System.Windows.Baml2006.Baml2006SchemaContext.GetProperty(Int16 propertyId, XamlType parentType)
[1580] at System.Windows.Baml2006.Baml2006Reader.Process_PropertyComplexStart()
[1580] at System.Windows.Baml2006.Baml2006Reader.Process_OneBamlRecord()
[1580] at System.Windows.Baml2006.Baml2006Reader.Process_BamlRecords()
[1580] at System.Windows.Baml2006.Baml2006Reader.Read()
[1580] at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
[1580] at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
Sep 25, 2013 at 7:42 AM
Can you build it in debug mode, load symbols from msdn, enable exceptions retrow and pinpoint the exact point of failure?
Also, have you tried a binary compare over the two files?
It seems the error is raised from the Ball reader, so it would seems framework versions are different somehow (if .net 4.5 is installed it replaces some .net 4.0 assemblies), but in such a case I don't understand why replacing the executable whould make any difference...
Sep 25, 2013 at 7:56 AM
Yes it still doesn't make any sense to us either. We were able to workaround the problem by upgrading to the latest version of CM. The exact cause still isn't understood, but the exception was thrown when CM called System.Windows.Interactivity.dll (stack trace below). The build machines do have .NET 4.5 installed and our solution targets 4.0 - could this have been the cause?

System.Windows.Interactivity.EventTriggerBase.OnEventImpl(System.Object, System.EventArgs)
MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)

Sep 25, 2013 at 9:56 AM
A machine where .NET 4.5 is installed uses different assemblies, even if .NET 4.0 is targeted (to make sure about this, go check the Framework folder and use ILSpy, you'll see that some .NET 4.0 assemblies are just placeholders).

From the stack trace it seems that the issue happens inside the constructor of the ActionMessage... if you could build CM from sources and use the generated PDB, maybe you could retrieve an even more meaningful stacktrace.
Sep 26, 2013 at 12:04 AM
Ok nevermind we were able to reproduce the crash again on another Windows 7 64 bit machine with the latest version of CM. This is essentially blocking development and testing for us so we're actively investigating now...
Sep 26, 2013 at 1:20 AM
Update: we just determined that builds coming from 2 out of 3 of our builds machines experience this issue. However, the builds from our third build machine work just fine, so it clearly is something related to our build machines and that the upgrade of CM had no bearing on this issue.

Any suggestions for which differences to look for between the build machines?
Sep 26, 2013 at 9:54 PM
We went ahead and just cloned the build machine that produced working builds to address this issue. We're lucky we had a machine that built properly otherwise I could see us spending days (if not weeks) trying to figure this out. If we have time in the future we'll go back and try to determine out what was different about the other two build machines that didn't produce working builds, but it's not a high priority for us now.