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.
After getting additional details on this topic I am able to reproduce easy same problem just by using Remote Desktop application. I've tried to create a test sample with single attached behavior but it did not failed so far so something else is involved in this event. From additional logging I was able to figure out that used RegionManager with XamDockManager might be involved in this event chain which is missing in test application.
Additionally, as I observed before it really creates new instance of SpreadSheet control or existing has been reset since worksheets disappearing but active sheet's data content remains shown. This is very unusual behavior and I am not sure how I could track this change so far. The investigation continues and once I will be able to reproduce the problem in test application I will upload test application.
I will post update later.
Provided dump file does not indicate any contained data but only stack trace of unhandled exception details. Thus does not provide any additional details. Also I am unable to reproduce this error on my Virtual PC so far even with customer provided more exact steps. So it is easy to reproduce for customer but not for me. Further analysis showed me that this error is part of our implemented workbook behavior and raised as part of property changed,
I wondering what owner has changed and from what value. The IWorkbookOwner is internal thus I cannot see any details. During my testing I've noticed once that spreadsheet tabs were reset to default (contained 1 instead of 10+ tabs) with name "Sheet1" while our workbook never containing this name but content was filled with previous sheet our data. Thus I have a feeling that default workbook is reloaded (coming with spreadsheet control itself) on activate and then our workbooks is assigned which causing this problem.
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)
I've requested more additional information about connection type to the Virtual PC from customer and screenshot. Any suggestions how I could get more accurate reason for this error? What is stored in IWorkbookOwner?
Hello Tomas,
Thank you for your update on this matter. I will continue to monitor this forum thread while I await your next update on this.
Please let me know if you have any other questions or concerns on this matter.
Hi Andrew,
I do have virtual PC and tried same behavior multiple times but never seen this error. I've asked user for more details on steps and memory dump file if possible which might be useful. Since it is vacation time it may take a week to get a reply. I will respond once I get more details.
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.