IndexOutOfRangeException when DependencyProperty.GlobalIndex reaches 32768 - by perlun

Status : 


Sign in
to vote
ID 778857 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/8/2013 12:47:23 PM
Access Restriction Public



Is there a global limit to the number of DependencyProperties (or actually Attached Properties) in the WPF (4.0) framework? We seem to have run into it.

We have built a sophisticated application framework on top of WPF. In this framework, a lot of DependencyProperties gets created dynamically. In extreme cases, we are talking about thousands of DependencyProperties.

Today, we ran into the wall. Suddenly, we start getting IndexOutOfRangeExceptions inside DependencyObject.SetValueCommon (full stacktrace below). Interestingly enough, this seems to coincide with the DependencyProperty in question having its GlobalIndex reaching 32768. Since this is one number higher than the max value of a signed 16-bit value, I strongly suspect this is a fixed limit in the WPF framework?

If so, it would be nice if the framework would detect this and throw a better (more clear) exception. Ideally, of course, it would be nice to be able to support a higher number of DPs but at the very least, the framework should detect and not just bail out.

See the attached file for a working example of how to reproduce the problem.

Please redirect this to someone in the WPF (Windows Presentation Foundation) team. Many thanks in advance.
Sign in to post a comment.
Posted by perlun on 2/12/2013 at 10:23 AM

Thanks for your comments. I think the exact implementation in our framework will have to be redesigned to work around this.

However, one interesting point of notice: it works fine in Silverlight... The limit seems to be higher there. (our platform supports both WPF and SL)
Posted by Microsoft on 2/12/2013 at 9:38 AM
Yes there is such a limit, arising from the representation of a single property-value, which stores the property index as a 16-bit integer (short). There are no plans to change this, as even very large applications use only 1000 or so DependencyProperties. Unfortunately, your framework falls outside the space for which WPF was designed.

The error reporting could be improved, but since this situation comes up so rarely it's not worth the expense to fix it. Sorry.
Posted by Microsoft on 2/10/2013 at 6:05 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 2/8/2013 at 12:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(