locked
"An item with the same key has already been added." RRS feed

  • Question

  •  

    I get an argument exception is Dispatcher.AddCausality that I don't understand.  What does this error mean?

     

    Here is the code that causes the exception:

     

    Code Snippet

     

    Causality causality = new Causality(Guid.NewGuid().ToString(), ExceptionPort);

    Dispatcher.AddCausality(causality);

     

     

    Assuming the "key" is the name of the causality, then there shouldn't be a problem, because each causality has a unique name. 

     

    It appears that the error is related to removal of causalities. My code removes causalities when they go out of scope using an IDisposable wrapper. If I comment out the RemoveCausality call then I no longer get the exception on AddCausality!

     

    I am using CCR v2.0.730.3

     

    -Erik

     

    Thursday, May 15, 2008 6:19 PM

Answers

  • can you post a bit more details or a simple repro case that can help us find this?

     

    Doing:

     

    AddCausality()

    RemoveCausality()

    AddCausality()

     

    cause this problem? Remember that removing causalities only works in the current thread context you are doing the Dispatchr.RemoveCausality() call. It does *not* remove them across all threads.

    Friday, May 16, 2008 10:00 PM

All replies

  • can you post a bit more details or a simple repro case that can help us find this?

     

    Doing:

     

    AddCausality()

    RemoveCausality()

    AddCausality()

     

    cause this problem? Remember that removing causalities only works in the current thread context you are doing the Dispatchr.RemoveCausality() call. It does *not* remove them across all threads.

    Friday, May 16, 2008 10:00 PM
  •  

    Well, I blew it. I can't reproduce this myself anymore.  It's hard to reproduce because the code interacts with a service outside of my control (Amazon SimpleDB)

     

    For what it is worth, I am certain that I wasn't removing causalities across threads. Under this assumption there might be a bug, right?  If I come across this problem again I'll work hard to get a reproducable case.

     

    -Erik

     

    Friday, May 16, 2008 11:18 PM