Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
925
Error Workbooks can not have multiple owners for xamSpreadsheetControl
posted

Hi,

Our customer encountered exception in xamSpreadsheet control. Based on description customer loaded this control view left it opened. After an hour or more he tried to access same application control and got exception with fallowing stack trace:

System.NotSupportedException: Workbooks can not have multiple owners
   bei Infragistics.Documents.Excel.Workbook.RegisterOwner(IWorkbookOwner owner)
   bei Infragistics.Controls.Grids.Core.Spreadsheet.OnWorkbookChanged(Workbook oldWorkbook, Workbook newWorkbook)
   bei Infragistics.Controls.Grids.Core.Spreadsheet.set_Workbook(Workbook value)
   bei Infragistics.Controls.Grids.XamSpreadsheet.<>c.<.cctor>b__365_42(XamSpreadsheet c, Object v)
   bei Infragistics.Controls.Grids.XamSpreadsheet.SetInnerProperty[T](T d, Object newValue, Action`2 setter, String propertyName)
   bei Infragistics.Controls.Grids.XamSpreadsheet.<>c.<.cctor>b__365_41(DependencyObject d, DependencyPropertyChangedEventArgs e)
   bei System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   bei System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   bei System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   bei System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   bei System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   bei System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   bei Infragistics.Controls.Grids.XamSpreadsheet.set_Workbook(Workbook value)
   bei EafClient.Editor.Core.Workbooks.SpreadsheetControl.SpreadsheetWorkbook.ApplyTo(XamSpreadsheet spreadsheetControl) in D:\TfsBuildAgent2017\_work\278\s\Source\Implementation\EafClient.Editor.Core\Workbooks\SpreadsheetControl\SpreadsheetWorkbook.cs:Zeile 97.
   bei EafClient.Editor.CellAutomation.EquipmentDictionary.Views.SpecificBehaviors.EquipmentDictionaryWorkbookBehavior.WorkbookDataChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) in D:\TfsBuildAgent2017\_work\278\s\Source\Implementation\EafClient.Editor.CellAutomation\EquipmentDictionary\Views\SpecificBehaviors\EquipmentDictionaryWorkbookBehavior.cs:Zeile 155.
   bei System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
  bei System.Windows.Freezable.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   bei System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   bei System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   bei System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   bei System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
   bei System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   bei System.Windows.Data.BindingExpression.Activate(Object item)
   bei System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
   bei System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
   bei MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
   bei MS.Internal.Data.DataBindEngine.Run(Object arg)
   bei MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
   bei System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
   bei System.Windows.ContextLayoutManager.UpdateLayout()
   bei System.Windows.UIElement.UpdateLayout()
   bei Infragistics.Windows.DataPresenter.GridUtilities.ProcessAsyncInvalidationsImpl()
   bei Infragistics.Windows.DataPresenter.GridUtilities.ProcessAsyncInvalidations()

Our code involved in stack trace just monitoring changes and then reapplying back the workbook. Here is line 155 from our code with ApplyTo:

var behaviorInstance = d as EquipmentDictionaryWorkbookBehavior;
(e.NewValue as IWorkbook)?.ApplyTo(behaviorInstance?.Spreadsheet);

And then setting back (line 97 in SpreadsheetWorkbook class):

		public void ApplyTo(XamSpreadsheet spreadsheetControl)
			=> spreadsheetControl.Workbook = mWorkbook;

The workbook behavior is grabbing active spreadsheet:

private XamSpreadsheet Spreadsheet => AssociatedObject.SpreadSheet;book;

What could cause this error if we use only 1 control in our application? No other user should be able to access this application during away time.

I don't know if it could be related, but this is Virtual PC and during this time auto lock of windows is enabled.

Parents
No Data
Reply
  • 34810
    Offline posted

    Hello Tomas,

    I have been investigating into the behavior you are seeing, and the exception you are seeing is being intentionally thrown from our internal code. This happens if the owner of the Workbook is not null when the RegisterOwner method is hit.

    I would like to get a bit more of an idea of how you are reproducing this behavior. You mentioned that you are using Virtual PC and auto-lock of Windows is enabled. I am curious if you run your application, lock your screen, and then unlock it if this behavior happens? I have personally tried this on my end, and it does not happen, but I am also not in a virtual environment, and perhaps that is the missing piece.

    Please let me know if you have any other questions or concerns on this matter.

Children