Upgrades Questions on upgrading to version 6.x.
Version 6.x > Upgrades > Upgraded from 5.5r2 to 6.0 View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 10/31/2012 10:46:39 PM
   
Upgraded from 5.5r2 to 6.0
Hi Guys,

Need some help with some changing API's between 5.5r2 and 6.0

We have upgraded the CMS to 6.0 and it gave some error messages.

I think I have found the solution for them but would like to have your suggestions:

1.
Error:
'CMS.TreeEngine.TreeNode' does not contain a definition for 'DataRow' and no extension method 'DataRow' accepting a first argument of type 'CMS.TreeEngine.TreeNode' could be found (are you missing a using directive or an assembly reference?)


Code Line:
CMSContext.CurrentDocument.DataRow["DocumentCreatedWhen"]


Solution:
CMSContext.CurrentDocument["DocumentCreatedWhen"]


Is this solution applied correct?

2.
Warning:
This method is now obsolete and gives warnings


Code Line:
 if(!CacheHelper.Contains(cacheItemName))


Solution:
object result = null;
if (!CacheHelper.TryGetItem(cacheItemName, out result))


Is this warning solved correctly?

3.
Error:
'object' does not contain a definition for 'ToLower' and no extension method 'ToLower' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

Code Line:
(CMSContext.CurrentDocument.NodeCustomData["excludefromsearch"] != null ? (CMSContext.CurrentDocument.NodeCustomData["excludefromsearch"].ToLower() == "true" ? "noindex,nofollow" : "index,follow") : "index,follow")));


Not sure about the solution here. Any ideas please?

Thanks for your help in advance.

Cheers
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/1/2012 4:23:21 AM
   
RE:Upgraded from 5.5r2 to 6.0
Hello.

Your solutions are basically correct. Regarding last example – you use also a standard String.ToLower() ASP.NET method and apply it to any variable of type string.

Please note, you can find more info about API changes from 5.5R2 to 6.0 at http://devnet.kentico.com/Blogs/Martin-Hejtmanek/November-2011/Changes-in-the-API-from-version-Kentico-CMS-5-5-R2.aspx

Best Regards,
Radek Macalik

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 11/1/2012 8:34:10 PM
   
RE:Upgraded from 5.5r2 to 6.0
Hi Radek,

Thanks for your recommendation. I have solved the last issue by writing .ToString().ToLower()

There is one more error coming:
[CMSAbstractTransformation.DataBind]: Object reference not set to an instance of an object.


From the below code:
Transformation Code:
<%# Common.GetPropertyDocs(""+Eval("BPKey")) %> 


Code Behind for the Transformation method:

public static string GetPropertyDocs(string PropertyId)
{
string docStr = "";
TreeProvider tp = new TreeProvider();

DataSet ds = tp.SelectNodes(CMSContext.CurrentSiteName, "/Media/%", CMSContext.CurrentUser.PreferredCultureCode,
true, "CMS.PropertyDoc", "PropertyIDs LIKE '%" + PropertyId + "%'", "DocumentName");

if (ds.Tables.Count > 0)
{
docStr += "<ul class =\"propertyDoc\">";
foreach (DataRow dr in ds.Tables[0].Rows)
{
Guid attachmentGuid = ValidationHelper.GetGuid(dr["Attachment"], Guid.Empty);
CMS.TreeEngine.AttachmentManager am = new CMS.TreeEngine.AttachmentManager();
CMS.TreeEngine.AttachmentInfo info = am.GetAttachmentInfo(attachmentGuid, CMSContext.CurrentSiteName);
string sAttachmentExt = info.AttachmentExtension;
string sLinkImg = "generic";
if (sAttachmentExt.Equals(".doc"))
sLinkImg = "word";
else if (sAttachmentExt.Equals(".xls"))
sLinkImg = "excel";
else if (sAttachmentExt.Equals(".pdf"))
sLinkImg = "pdf";

string sAttachmentURL = "/CMSPages/GetFile.aspx?guid=" + dr["Attachment"];
docStr += "<li><a href=\"" + sAttachmentURL + "\"><img src=\"~/App_Themes/Bayleys/Images/icon_" + sLinkImg + ".gif\" height=\"12px\" width=\"12px\" />" + dr["DocumentName"] + "</a></li>";
}
docStr += "</ul>";
}

return docStr;
}


I have tried many different things to give a default value but still it throws this error.

Any ideas what am I doing wrong?

Thanks
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/13/2012 3:29:08 AM
   
RE:Upgraded from 5.5r2 to 6.0
Hello.

It seems that something is wrong in your custom code. Maybe some object your custom code works with is not properly initialized at the moment of the code execution.

Could you please check if there is any Event log entry regarding this issue?

Could you please try to debug that C# code to see where it fails and what object causes this problem? Thank you.

Best Regards,
Radek Macalik