我需要维护一个旧的旧版 Windows 窗体应用程序。我只是得到源代码,没有文档或任何东西。我正在使用在 64 位 Windows 8.1 上运行并使用 .NET Framework 4.5 的 Visual Studio 2015 构建应用程序。一切正常,除了一件事,一个名为 FileViewer 的 VbPowerPack(版本 1.0.1644.16184,完全过时)控件用于显示文件夹的内容,它只是在第一次将该窗格设置为可见时抛出异常
System.OverflowException: Arithmetic operation resulted in an overflow.
at System.IntPtr.ToInt32()
at VbPowerPack.ShellFolder.GetTypeDescriptionForFile(String in_path) in C:\Documents and Settings\Ken\My Documents\Visual Studio Projects\VbPowerPack Source\VbPowerPack\ShellFolder.vb:line 264
at VbPowerPack.FileViewer.populateControl() in C:\Documents and Settings\Ken\My Documents\Visual Studio Projects\VbPowerPack Source\VbPowerPack\FileViewer.vb:line 992
at VbPowerPack.FileViewer.CreateHandle() in C:\Documents and Settings\Ken\My Documents\Visual Studio Projects\VbPowerPack Source\VbPowerPack\FileViewer.vb:line 866
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.TabPage.set_Visible(Boolean value)
at System.Windows.Forms.TabControl.UpdateTabSelection(Boolean updateFocus)
at System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.TabControl.WmSelChange()
at System.Windows.Forms.TabControl.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
(请注意,我没有在异常中提到 Ken,DLL 必须是在他的计算机上编译的,如果我使用在 Internet 上找到的同一 DLL 的另一个实例,我会得到相同的异常,只是没有 Ken 部分)
之后,如果单击“未处理的异常窗口”中的“继续”并单击另一个选项卡,然后再次尝试此选项卡,它会显示控件而不会再次引发异常,但文件夹内容不存在。
我尝试在此解决方案内新创建的空 Windows 窗体项目中添加相同的控件和新窗体,它的行为相同。但是,当我使用新的 Windows 窗体项目创建一个新的空解决方案并仅使用 FileViewer 控件时,它可以正常工作。当我在设计视图中打开表单(不运行应用程序)时,它也适用于有问题的解决方案,它向我显示文件夹内容。我尝试调试,但在触发任何事件(如“VisibleChanged”)之前引发了异常。我还尝试注释掉任何其他可能影响这一点但没有运气的代码。这是控件的初始化方式
public partial class DocumentsForm
{
private VbPowerPack.FileViewer fileViewer;
...
private void InitializeComponent()
{
this.fileViewer = new VbPowerPack.FileViewer();
...
this.fileViewer.AllowDrop = true;
this.fileViewer.ContextMenu = this.contextMenuFiles;
this.fileViewer.Dock = System.Windows.Forms.DockStyle.Fill;
this.fileViewer.HideSelection = false;
this.fileViewer.Location = new System.Drawing.Point(0, 34);
this.fileViewer.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.fileViewer.Name = "fileViewer";
this.fileViewer.Path = "c:\\";
this.fileViewer.Size = new System.Drawing.Size(842, 482);
this.fileViewer.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.fileViewer.TabIndex = 0;
this.fileViewer.UseCompatibleStateImageBehavior = false;
this.fileViewer.ItemClicked += new VbPowerPack.FileViewer.ItemClickedEventHandler(this.fileViewer_ItemClicked);
this.fileViewer.ItemDoubleClicked += new VbPowerPack.FileViewer.ItemDoubleClickedEventHandler(this.fileViewer_ItemDoubleClicked);
this.fileViewer.LocationChanged += new System.EventHandler(this.fileViewer_LocationChanged);
this.fileViewer.VisibleChanged += new System.EventHandler(this.fileViewer_VisibleChanged);
this.fileViewer.DragDrop += new System.Windows.Forms.DragEventHandler(this.fileViewer_DragDrop);
this.fileViewer.DragEnter += new System.Windows.Forms.DragEventHandler(this.fileViewer_DragEnter);
...
this.Controls.Add(this.fileViewer);
...
}
}
现在挣扎了几天。欢迎任何帮助和建议。