Exception on NotifyPropertyChanged property

Sam's Avatar

Sam

19 Feb, 2015 09:04 PM

Occasionally I'm getting a Postsharp related exception from the NotifyPropertyChanged attribute I have applied to a class:

System.ArgumentException: An item with the same key has already been added. at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at PostSharp.Patterns.Model.NotifyPropertyChanged.DependencyAnalysis.LocationRecordStore.AddField(Type genericTypeInstance, String locationName, String locationFullName, Type locationType, Type declaringType, ILocationBinding locationBinding) at PostSharp.Patterns.Model.NotifyPropertyChangedAttribute.OnFieldSet(LocationInterceptionArgs args)

I'm not sure what triggers this as it doesn't happen all the time. Is there anything I can do to track down the source of this problem and fix it?

Thanks.

  1. Support Staff 1 Posted by PostSharp Techn... on 20 Feb, 2015 06:29 PM

    PostSharp Technologies's Avatar

    Hello,

    what version of PostSharp are you using?

    Does it happen during each build (meaning without changed code) or only occasionally?

    Thanks!

    Best,
    Daniel

  2. 2 Posted by Sam on 20 Feb, 2015 06:32 PM

    Sam's Avatar

    It happens at runtime and only occasionally. I'm using version 4.0.41.0 of the PostSharp.Patterns.Model library which contains this aspect.

  3. Support Staff 3 Posted by PostSharp Techn... on 20 Feb, 2015 06:35 PM

    PostSharp Technologies's Avatar

    Hello Sam,

    So it is not deterministic?
    Are you using NPC-enhanced classes in multithreaded environment?

    Thanks!

    Best,
    Daniel

  4. 4 Posted by Sam on 20 Feb, 2015 08:20 PM

    Sam's Avatar

    It is not deterministic. It is a multi-threaded environment but there should never be more than one thread accessing a property at once.

  5. Support Staff 5 Posted by PostSharp Techn... on 22 Feb, 2015 01:13 PM

    PostSharp Technologies's Avatar

    Thanks for the information.

    Multithreaded environment is supported, so it looks like a bug. I'll take a look at the code and let you know.

  6. Support Staff 6 Posted by PostSharp Techn... on 22 Feb, 2015 01:34 PM

    PostSharp Technologies's Avatar

    I have found the bug in our code.

    (internal issue #10960)

    Anyway, this crash means that you are probably accessing the property from multiple threads (which is still correct use case).

    Thanks for reporting it.

  7. 7 Posted by Sam on 23 Feb, 2015 03:58 PM

    Sam's Avatar

    Could you give me a rough estimate of when you expect the fix to be released?

  8. Support Staff 8 Posted by PostSharp Techn... on 24 Feb, 2015 09:02 AM

    PostSharp Technologies's Avatar

    Hello,

    we expect that this fix will be available in version 4.0.43. The exact release date is not exactly determined yet but it could be at the end of the next week (March 6) or at the beginning of the week starting on March 8.

    -jakub

  9. Support Staff 9 Posted by PostSharp Techn... on 26 Mar, 2015 03:29 PM

    PostSharp Technologies's Avatar

    Hello,

    first, sorry for the late notice (we have somehow lost the reference to this discussion).

    This issue was fixed in 4.0.43.

    Best regards,
    Daniel

  10. System closed this discussion on 13 Apr, 2016 10:34 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac