|  | 分類:[.NET 全般]
 
 
 はじめまして、おだ といいます。
質問についてですが、
DataTable.RowChangedイベントで発生した例外が握り潰される
という現象が発生しています。
(DataRowの追加時、任意の列の値変更時とも同様です)
何か情報をお持ちの方が居られましたら、教えて頂けないでしょうか。
※急ぎで困っているという訳ではありません。
以下環境と再現コードです。
「環境」
WindowsXP SP2
Visual Studio 2005
.NET Framework:2.0.50727
「再現コード」
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace RowChangedTest
{
  class Program
  {
    static void Main(string[] args)
    {
      DataTable table = new DataTable("TABLE_1");
      DataColumn column1 = table.Columns.Add("COL_1", typeof(string));
      DataColumn column2 = table.Columns.Add("COL_2", typeof(decimal));
      table.RowChanging += new DataRowChangeEventHandler(table_RowChanging);
      table.RowChanged += new DataRowChangeEventHandler(table_RowChanged);
      table.Rows.Add("ABC", 1m);
      Console.ReadKey();
    }
    static void table_RowChanging(object sender, DataRowChangeEventArgs e)
    {
      Console.WriteLine("RowChanging");
      // ここでは、落ちる
      //throw new Exception("The method or operation is not implemented.");
    }
    static void table_RowChanged(object sender, DataRowChangeEventArgs e)
    {
      Console.WriteLine("RowChanged");
      // ここは、落ちない
      throw new Exception("The method or operation is not implemented.");
    }
  }
}
 |