开发者

Exception handling internal bug

Code:

public static void Test()
{
   try
   {
       OpenConnectionToDatabase(); //Opens a connection to Oracle DB

   } catch(Exception e)
   {
       e.Data.Add("Query:", command.CommandText);
       throw e;
   }
}

Wh开发者_如何学编程en this code is executed when the Database server is being shutdown and the communication is disrupted, .NET throws the following error: Item has already been added. Key in dictionary: 'Query:' Key being added: 'Query:' at System.Collections.ListDictionaryInternal.Add(Object key, Object value)

How can this be?


EDIT: (based on @LukeH's comment)

e.Data["Query:"] = command.CommandText;


Don't use "throw e;". Just use throw.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜