Maximum number static fields allowed in mscorlib?
The maximum number of static fields allowed in mscorlib?
1020
Yep you read that right, an arbitrary 1020, not even a computer-scientisty power-of-2, like 1024. Static fields are scoped per AppDomain and this limitation is hardcoded in the native implementation of that class. Check out the Rotor source if you are interested (search for STATIC_OBJECT_TABLE_BUCKET_SIZE):
sscli20\sscli20\clr\src\vm\AppDomain.cpp
Have a guess how a colleague of mine, Brian Grunkemeyer, found this out today…
(This limitation is only in mscorlib – other assemblies do not have a limitation, or rather, have an insanely high limit that you should never hit)