I know it's crazy but I'm facing an unexpected and really triggering issue. When started, my application (vb.net desktop app in .net 4.7 fmk) reads an xml file containing some local settings for the app. Now, the issue is that if I login into windows as administrator everything is fine. If I access as a normal user, the file itself is not read properly. The app gives me this error
System.IndexOutOfRangeException(0x80131508): No row at position 12. in System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex) in System.Data.DataRowCollection.get_Item(Int32 index) in Health.NET.FrmLogin.OnLoad(EventArgs e)
In the XML row 12 actually exists. The xml file is the same despite the user that log in windows. Two even more weird effects: 1- that the error comes at row 12, but some of the previous rows are read returning zero values even if the xml has no zero values for that setting. 2- this error occurs only on one client in an environment of 30 clients.
Basically it's the first time this happens in 7 years of application's honored service.
Does anybody has any clue to solve this craziness??
Here's some raw code I'm using. It's pretty standard code
Dim ds As New DataSet
Dim Path as string = ""
path = Application.StartupPath & "\LocalConfig.xml"
ds.ReadXml(path)
' Set theme and LabelsPrinter
If Not ds.Tables.Item(0).Rows(0).Item(0).ToString = String.Empty Then
theme.Name = ds.Tables.Item(0).Rows(0).Item(0).ToString
End If
If Not ds.Tables.Item(0).Rows(2).Item(0).ToString = String.Empty Then
LocalConfig.labelsPrinterName = ds.Tables.Item(0).Rows(2).Item(0).ToString
End If
So far everything is read correct, and the same for few lines ahead But when coming to this:
' Set LabelsSettings
If Not ds.Tables.Item(0).Rows(7).Item(0).ToString = String.Empty Then
LocalConfig.LabelMarginTop = ds.Tables.Item(0).Rows(7).Item(0)
End If
If Not ds.Tables.Item(0).Rows(8).Item(0).ToString = String.Empty Then
LocalConfig.LabelMarginLeft = ds.Tables.Item(0).Rows(8).Item(0)
End If
THESE ARE READ BUT WITH 0 value instead of a given non zero value
If Not ds.Tables.Item(0).Rows(9).Item(0).ToString = String.Empty Then LocalConfig.UseLabelSettings = ds.Tables.Item(0).Rows(9).Item(0) End If ' Set Other Settings If Not ds.Tables.Item(0).Rows(10).Item(0).ToString = String.Empty Then LocalConfig.DefaultZoomMinutes = ds.Tables.Item(0).Rows(10).Item(0) End If If Not ds.Tables.Item(0).Rows(11).Item(0).ToString = String.Empty Then LocalConfig.DefaultKeepActualPlanningOnAddNew = ds.Tables.Item(0).Rows(11).Item(0) End If
THE 3 previous lines ARE READ correct
If Not ds.Tables.Item(0).Rows(12).Item(0).ToString = String.Empty Then LocalConfig.LabelPaperSizeX = ds.Tables.Item(0).Rows(12).Item(0) End If If Not ds.Tables.Item(0).Rows(13).Item(0).ToString = String.Empty Then LocalConfig.LabelPaperSizeY = ds.Tables.Item(0).Rows(13).Item(0) End If
Try to read row 12 throws the error, even if it is actually in the XML
I stand it again: as administrator logged in, everything is fine
Please HELP
EDIT: If logged with a regular user but start the app with admin privilege everything works fine :-O The folder containing the xml has full control for 'Everyone' set