Upgrades Questions on upgrading to version 4.x.
Version 4.x > Upgrades > Error upgrading 4.0 to 4.1 View modes: 
User avatar
Member
Member
ramon.almarza-emtmadrid - 6/29/2010 5:59:01 AM
   
Error upgrading 4.0 to 4.1
Hi,

We have applying upgrate to 4.1 version, but we have the next error in our code:

Error de servidor en la aplicación '/'.
________________________________________
Referencia a objeto no establecida como instancia de un objeto.
Descripción: Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.

Detalles de la excepción: System.NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.

Error de código fuente:

Lìnea 344:
Lìnea 345: CMS.TreeEngine.TreeNode nodo;
Lìnea 346: if (ds.Tables.Count > 0)
Lìnea 347: {
Lìnea 348: foreach (DataRow dr in ds.Tables[0].Rows)

Archivo de origen: d:\wwwroot\App_Code\Babel\Util.cs Lìnea: 346

Seguimiento de la pila:

[NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.]
Util.SelectNodesByPath(String path, String className, Boolean selectHiddenPages) in d:\wwwroot\App_Code\Babel\Util.cs:346
CMSWebParts_Babel_listmenu.makeMenu(TreeNode nodo) in d:\wwwroot\CMSWebParts\Babel\ListMenu.ascx.cs:277
CMSWebParts_Babel_listmenu.makeMenu() in d:\wwwroot\CMSWebParts\Babel\ListMenu.ascx.cs:261
CMSWebParts_Babel_listmenu.SetupControl() in d:\wwwroot\CMSWebParts\Babel\ListMenu.ascx.cs:240
CMSWebParts_Babel_listmenu.OnContentLoaded() in d:\wwwroot\CMSWebParts\Babel\ListMenu.ascx.cs:217
CMS.PortalControls.CMSAbstractWebPart.OnLoad(EventArgs e) +222
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

________________________________________
Información de versión: Versión de Microsoft .NET Framework:2.0.50727.3603; Versión ASP.NET:2.0.50727.3614

And this is our code:

public static List<CMS.TreeEngine.TreeNode> SelectNodesByPath(string path, string className, bool selectHiddenPages)
{
List<CMS.TreeEngine.TreeNode> listaNodos = new List<CMS.TreeEngine.TreeNode>();
DataSet ds = Functions.GetTreeProvider().SelectNodes(GetSiteName(), path + "/%", Functions.GetPreferredCulture(), true, className, "", "NodeOrder", 1);

CMS.TreeEngine.TreeNode nodo;
if (ds.Tables.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
CMS.PortalEngine.PageInfo pi = new CMS.PortalEngine.PageInfo(dr);
nodo = new CMS.TreeEngine.TreeNode(dr, className);
if (!pi.DocumentMenuItemHideInNavigation || selectHiddenPages)
listaNodos.Add(new CMS.TreeEngine.TreeNode(dr, className));
}
}
return listaNodos;
}

I suppose that something has changed in new version but I don´t know what. Could you help us, please?

Thanks in advance,


User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 6/29/2010 10:47:16 AM
   
RE:Error upgrading 4.0 to 4.1
Hi,

You can check if DataSet is empty using following method before using its Tables.Count properties:

CMS.GlobalHelper.DataHelper.DataSourceIsEmpty(Object)

I hope this will help you.

Best regards,
Miroslav Remias.