Expand Minimize

Reference 15 hive in strings within code

References in strings in the code to hive folder '/_controltemplates', '/_layouts' and '/_layouts/images/' must be changed accordingly to point to the 15 hive (e.g. by changing to '/_controltemplates/15/').

CheckId SPC150208
TypeName ReplaceReferencesToOlderHivesInCode
Severity Warning
Type Assembly

Change all strings in code which contains '/_controltemplates', '/_layouts' or '/_layouts/images/' to a correct path to 15 hive: '/_controltemplates/15/', '/_layouts/15/' or '/_layouts/15/images/'. See sample below:

protected override void CreateChildControls()
{
   var smallUserControl = this.Page.LoadControl("~/_CONTROLTEMPLATES/15/Company/smallUserControl.ascx");
   this.Controls.Add(smallUserControl);
}

To suppress this violation in managed code add the following attribute to the method which contains the instruction (available since SPCAF version v5.2). Learn more about SuppressMessage here.

// Important: Ensure to have #define CODE_ANALYSIS at the beginning of your .cs file
[SuppressMessage("SPCAF.Rules.SP15CompatibilityGroup", "SPC150208:ReplaceReferencesToOlderHivesInCode", Justification = "Provide reason for suppression here")]
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.