My project is in WPF using MVVM. I am using Interaction,Triggers -> i:EventTrigger to notify about any validation errors in control.
This application works all the time and already in production. But last week, we found out a client has a problem loading a view. Application crashes while loading the view. And it happens all the time. We can not reproduce it in out environment.
The following details were captured from client machine.
Errors in Event Viewer => Message: HandlingInstanceID: 01453795-4b3a-4765-b651-44c11594b402 An exception of type 'System.Windows.Markup.XamlParseException'
occurred and was caught.
03/31/2016 15:16:09 Type : System.Windows.Markup.XamlParseException, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Message : Add value to collection of type 'System.Windows.Interactivity.TriggerActionCollection' threw
an exception. Source : PresentationFramework Help link : LineNumber : 0 Line"margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono',
'Courier New', monospace, sans-serif;white-space:pre-wrap;background-color:#eff0f1;">1 affectedChildren, UncommonField1 templatedNonFeChildrenField) at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List1
affectedChildren) at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField
1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate)
.................... (Very long stack trace)
**InnerException**---------------Type:System.ArgumentException, mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089Message:Cannot add instance of type 'EventToCommand' to a collection of type 'TriggerActionCollection'.Only items of type 'T' are allowed.Source:PresentationCoreHelp link :ParamName:Data:System.Collections.ListDictionaryInternalTargetSite: T Cast(System.Object)HResult:-2147024809StackTrace: at System.Windows.FreezableCollection`1.Cast(Object value)
at System.Windows.FreezableCollection`1.System.Collections.IList.Add(Object value)
at System.Xaml.Schema.XamlTypeInvoker.AddToCollection(Object instance,Object item)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.Add(Object collection,XamlType collectionType,Object value,XamlType valueXamlType)
Another Exception
04/21/2016 11:52:09 Type : EAF.Infrastructure.Exceptions.DevicePartDiscoveryException, EAF.Infrastructure, Version=1.0.1.538, Culture=neutral, PublicKeyToken=null Message : A module cannot be imported. The following issues were found while trying to import
a module: Could not load file or assembly 'System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Inner Exception --------------- Type : System.Reflection.ReflectionTypeLoadException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property
for more information. Source : mscorlib Help link : Types : System.RuntimeType[] LoaderExceptions : System.Exception[] Data : System.Collections.ListDictionaryInternal TargetSite : System.RuntimeType[] GetTypes(System.Reflection.RuntimeModule) HResult : -2146232830
Stack Trace : at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeModule.GetTypes() ......................
I already checked the version of System.Windows.Interactivity and its correct version.(I am using .Net framework 4.5)