VB6から.NETに自動コンバート(VS2008)した画面で、spread7(COM)を.NET版spreadに差し替えたら、
画面表示後、パッと見動いてたけど、画面遷移時にエラーで落ちた。
エラー内容
************** 例外テキスト ************** System.Exception: Exception handled in FpSpread.WndProc ---> System.NullReferenceException: オブジェクト参照がオブジェクト インスタンスに設定されていません。 場所 FarPoint.Win.Spread.CellType.ComboBoxCellType.Format(Object o) 場所 FarPoint.Win.Spread.CellType.ComboBoxCellType.IsValid(Object value) 場所 FarPoint.Win.Spread.SpreadView.StopCellEditing() 場所 FarPoint.Win.Spread.SpreadView.i(Object A_0, EventArgs A_1) 場所 System.Windows.Forms.Control.OnLostFocus(EventArgs e) 場所 FarPoint.Win.FpCombo.OnLostFocus(EventArgs e) 場所 System.Windows.Forms.Control.WmKillFocus(Message& m) 場所 System.Windows.Forms.Control.WndProc(Message& m) 場所 FarPoint.Win.SuperEditBase.WndProc(Message& m) 場所 FarPoint.Win.FpCombo.WndProc(Message& m) 場所 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 場所 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 場所 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 場所 System.Windows.Forms.UnsafeNativeMethods.SetFocus(HandleRef hWnd) 場所 System.Windows.Forms.Control.FocusInternal() 場所 System.Windows.Forms.Control.Focus() 場所 FarPoint.Win.Spread.SpreadView.b(MouseEventArgs A_0) 場所 FarPoint.Win.Spread.FpSpread.OnMouseDown(MouseEventArgs e) 場所 System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) 場所 System.Windows.Forms.Control.WndProc(Message& m) 場所 FarPoint.Win.Spread.FpSpread.WndProc(Message& m) --- 内部例外スタック トレースの終わり --- 場所 FarPoint.Win.Spread.FpSpread.WndProc(Message& m) 場所 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 場所 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 場所 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
調べてみたら原因はComboBoxCellTypeの作成時に、
Itemsに渡すstring配列(下のlsList)の1番目がNothingになっていたためだった。空文字にしたらOK。
自動コンバートした直後は動いていたってことは、
spread7ラッパーがNothingをString.Emptyに読み替えて処理するのかなぁ(結局差し替えるからどうでもいい…)
Dim combo As New FarPoint.Win.Spread.CellType.ComboBoxCellType combo.Items = lsList spread.ActiveSheet.Cells(0, 1, 2, 1).CellType = combo
実行環境
windowsXP sp3 VS2008/FW3.5 FarPoint.Win.SpreadJ アセンブリ バージョン: 3.0.2010.2005 Win32 バージョン: 3.0.2010.2005