We are getting this error periodically when working within a context menu in our application. Is this a known issue, any idea about how to fix? Thanks!
System.NullReferenceException: Object reference not set to an instance of an object.
at DevExpress.Xpf.Bars.BarSubItemLink.get_CanOpenMenuCore()
at DevExpress.Xpf.Bars.BarSubItemLink.get_CanOpenMenu()
at DevExpress.Xpf.Bars.BarSubItemLinkControl.GetCanOpenMenu()
at DevExpress.Xpf.Bars.BarSubItemLinkControl.OnIsPressedCoerce(Object value)
at DevExpress.Xpf.Bars.BarItemLinkControl.<.cctor>b__8(DependencyObject d, Object e)
at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at DevExpress.Xpf.Bars.BarItemLinkControl.set_IsPressed(Boolean value)
at DevExpress.Xpf.Bars.BarSubItemLinkControl.ShowPopup()
at DevExpress.Xpf.Bars.PopupMenuManager.ShowPopup(BarPopupBase popup, Action showPopupAction)
at DevExpress.Xpf.Bars.PopupMenuManager.OnShowPopupTimerTick(Object sender, EventArgs e)
at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Window.ShowDialog()
at Summit.Exchange.Client.App.Application_Startup(Object sender, StartupEventArgs e) in C:\TFS\Summit.Products\Development\Summit.Exchange\Summit.Exchange.Client\App.xaml.cs:line 108
at System.Windows.Application.OnStartup(StartupEventArgs e)
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at Summit.Exchange.Client.App.Main()
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Hi Paul,
I could not find any reports with a similar call stack in our database. Can you reproduce the exception in a sample project? Also, is it possible for you to upgrade to a more recent version to see if the exception is resolved there?
Thanks,
Alex
We are close to releasing a build so upgrading at this point is not possible and I don't have time to port a duplicate to a sample project.
This ticket seemed to have a similar problem that was fixed in the release just before the one we are using? Any details on what was fixed?
Hi Paul,
I have not managed to find fixed issues with a similar callstack. Would you please clarify what issue you mean?
Nevertheless, our developers reviewed your callstack, and they are ready to add the required check to the CanOpenMenuCore property. Since the production cycle for the version you specified (15.1) is ended and you cannot upgrade at the moment, I would like to provide you with an immediate workaround. The workaround is to replace BarSubItemLink objects in your application with a BarSubItemLinkEx descendant from my sample. If you don't create links manually, it will be sufficient to copy the descendant to your project and register it:
static MainWindow() { BarItemLinkCreator.Default.RegisterObject(typeof(BarSubItem), typeof(BarSubItemLink), x => new BarSubItemLinkEx()); }
Thanks
I've tried your approach and I got a different exception shown below. The bar items are defined in a resource dictionary. If I choose to set the property 'CheckBarItemNames' to false I am still able to reproduce the exception. Thank you for your efforts. Is there something else I could try?
Exception thrown: 'System.Windows.Markup.XamlParseException' in PresentationFramework.dll
Additional information: BarItemLink refers to unsupported BarItem. Cannot assign BarItemLink with BarItem by name: "itemInboundAddSender".
To suppress this exception, set BarManager.CheckBarItemNames static property to False
Hi again,
This exception may occur if you did not replace BarSubItemLink with BarSubItemLinkEx in your code. Since the workaround is implemented in the BarSubItemLink class descendant, it will be necessary to modify your implementation in the following manner:
<dxb:ToolBarControl> <dxb:BarSubItem Content="BarSubItem" Name="item"> <dxb:BarButtonItem Content="BarButtonItem"/> </dxb:BarSubItem> <!--<dxb:BarSubItemLink BarItemName="item"/>--> <local:BarSubItemLinkEx BarItemName="item"/> </dxb:ToolBarControl>
local in the code snippet above is a namespace where the BarSubItemLinkEx class is declared.