This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, If the Value of a Node is a 'INotifyCollectionChanged' object it hooks into its 'CollectionChanged' event (in the version of the Property Grid code I have in Node.cs line 183 in the 'Children' property) however I am finding that this appears to not get unhooked when the Node (i.e. the item in the collection) is removed. Specifically, I have a collection of collections in the Property Grid and if I remove, say, the 3rd item of the top level collection that has 4 items in it and then try and add a new item to what was the fourth item (and is now the third) I get a 'Exception has been thrown by the target of an invocation' with this stack trace: Mindscape.WpfPropertyGrid.dll!Mindscape.WpfPropertyGrid.PassthroughPropertyInfoAdapter.GetValue(...) Line 41 + 0x23 bytes C# A workaround (for my code) is to wrap the CollectionChanged event calling in a try/catch but it would suggest a memory leak in that old CollectionElements arn't getting removed (I think). Even when I clear the Property Grid selection object and re-select my collection object it still occurs. |
|
|
Hello Adam, I haven't been able to reproduce the exception you're seeing. From the line numbers you quote, there have been changes to the Node.cs file since the build you're using, but I'm not sure whether these have fixed the exception or whether I'm just not setting up the right conditions. I'm going to have a look at the potential memory leak you identified, but would it be possible for you to provide a simple repro project so that I can make sure I nail your exception problem while I'm in there? (You can attach a zip file via the Options tab.) Thanks! |
|
|
Hi Ivan, I've attached a repro project. Repro steps: 1. Click Add Button twice;
Cheers |
|
|
Thank you for the repro. I have committed a candidate fix which will be included in the 11 June nightly build, available from about 1500 GMT. (It should also address the potential memory leak you noted.) This has made some changes to the way events are unhooked, so I'd advise thorough regression testing if you have complex collection hierarchies. As always, let us know it doesn't fix the problem or if you find any bugs, and thanks for alerting us to the issue. |
|