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
.
精彩评论