我知道这很疯狂,但我正面临一个意想不到且真正触发的问题。启动时,我的应用程序(.net 4.7 fmk 中的 vb.net 桌面应用程序)读取一个 xml 文件,其中包含应用程序的一些本地设置。现在,问题是如果我以管理员身份登录 Windows,一切都很好。如果我以普通用户身份访问,则文件本身无法正确读取。该应用程序给了我这个错误
System.IndexOutOfRangeException(0x80131508):在 System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex) in System.Data.DataRowCollection.get_Item(Int32 index) 中的位置 12 处没有行 Health.NET.FrmLogin.OnLoad(EventArgs e )
在 XML 行中实际存在 12 行。尽管用户登录 Windows,但 xml 文件是相同的。两个更奇怪的效果:1-错误出现在第 12 行,但是即使 xml 没有该设置的零值,前面的一些行也被读取返回零值。2- 此错误仅发生在 30 个客户端的环境中的一个客户端上。
基本上这是应用程序的荣幸服务7年来第一次发生这种情况。
有没有人有任何线索来解决这个疯狂?
这是我正在使用的一些原始代码。这是非常标准的代码
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
到目前为止,一切都是正确的,前面几行也是如此但是当谈到这一点时:
' 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
这些被读取但带有 0 值而不是给定的非零值
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
前 3 行是正确的
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
尝试读取第 12 行会引发错误,即使它实际上在 XML 中
我再次忍受:作为管理员登录,一切都很好
请帮忙
编辑:如果使用普通用户登录,但以管理员权限启动应用程序,一切正常:-O 包含 xml 的文件夹对“所有人”集具有完全控制权