SPC100206: Do not create static fields and properties |
SPC100206: Do not create static fields and properties |
Avoid creating static fields and properties in your sandboxed code.
TypeName: | DoNotCreateStaticMembers |
CheckId: | SPC100206 |
Severity: | Error |
Type: | AssemblyFileReference |
When a specific sandboxed solution is handled for the first time on a given server that is running the SharePoint Foundation Sandboxed Code Service (sometimes called the User Code Host Service), the service creates an application domain for it in a sandboxed worker process, and all static variables in the solution code are loaded into the domain. The application domain stays alive after the sandboxed solution finishes and is reused if that same sandboxed solution is requested again, perhaps by a different user on a different site collection. A side effect of this system is that the static values are not reloaded, and these values are not necessarily appropriate to every execution of the sandboxed solution in every context. For example, suppose the solution code puts SPContext.Current into a static field named myContext. If the same solution is requested from another site collection, the value of myContext.Site is incorrect.
comments powered by Disqus
Copyright © 2013 RENCORE AB. All Rights Reserved
Disclaimer: The views and opinions expressed in this documentation and in SPCAF are those of the creators and do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. All trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners. SharePoint Code Analysis Framework, Version 4.5.2.7855, see www.spcaf.com for more information |