Technical support This forum is closed.
Version 1.x > Technical support > ERROR: Searching causes Object reference View modes: 
User avatar
Member
Member
wtijsma - 1/19/2005 12:29:18 PM
   
ERROR: Searching causes Object reference
Hi Petr,

Error trapping & debugging is very hard because you don't throw useful errors, could you please put some attention to this? As I said before, always trow errors if something goes wrong in a function, don't just return 'nothing' because it will cause problems in other parts of your application.

Error below while searching:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 451: queriesNode = mXML.CreateNode(XmlNodeType.Element, "queries", "");
Line 452: queriesNode.InnerXml = queriesXML.InnerXml;
Line 453: mXML.SelectSingleNode("/applications/application[@id='" + applicationName.ToLower() + "']/classes/class[@id='" + className.ToLower() + "']").AppendChild(queriesNode.SelectSingleNode("queries"));
Line 454: }
Line 455: }


Source File: C:\Projecten\Website\trunk\src\MetadataEngine_cs\MetadataProvider.cs Line: 453

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
Kentico.CMS.MetadataEngine.MetadataProvider.EnsureQueries(String applicationName, String className) in C:\Projecten\Website\trunk\src\MetadataEngine_cs\MetadataProvider.cs:453
Kentico.CMS.MetadataEngine.MetadataProvider.GetQuery(String queryName) in C:\Projecten\Website\trunk\src\MetadataEngine_cs\MetadataProvider.cs:73
Kentico.CMS.DataEngine.GeneralConnection.RunQuery(String queryName, Object[,] paramsIdent) in C:\Projecten\Website\trunk\src\DataEngine_cs\GeneralConnection.cs:122
Kentico.CMS.DataEngine.GeneralConnection.ExecuteQuery(String queryName, Object[,] paramsIdent) in C:\Projecten\Website\trunk\src\DataEngine_cs\GeneralConnection.cs:89
Kentico.CMS.TreeEngine.TreeProvider.Search(String searchNodePath, TreePathTypeEnum pathType, String searchExpression, SearchModeEnum searchMode, Boolean searchChildNodes, String[] classNames, Boolean filterResultsByReadPermission) in C:\Projecten\Website\trunk\src\TreeEngine_cs\TreeProvider.cs:924
Kentico.CMS.CMSControls.CMSSearchResults.Render(HtmlTextWriter output) in c:\projecten\website\trunk\src\cmscontrols_cs\cmssearchresults.cs:323
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
ASP.search_aspx.__Render__control3(HtmlTextWriter __output, Control parameterContainer) in C:\Projecten\Website\trunk\src\Vitsol\search.aspx:35
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
ASP.search_aspx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) in C:\Projecten\Website\trunk\src\Vitsol\search.aspx:22
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Page.ProcessRequestMain()



User avatar
Guest
admin - 2/3/2005 4:22:25 PM
   
Re: ERROR: Searching causes Object reference
Hi Wiebe,

we will sure add more useful exceptions in the code review that we plan after version 1.6.

For this error: could you please try to check that all document templates have the "searchtree" query in their settings in the Development module and that this query is not empty?

Thank you.

User avatar
Member
Member
wtijsma - 2/4/2005 9:32:29 AM
   
Re: ERROR: Searching causes Object reference
Hi, Yes, it's solved, it had something to do with invalid metadata, thanks. Could I also leave the searchtree query out to prevent searching this document?

User avatar
Guest
admin - 2/7/2005 3:10:44 PM
   
Re: ERROR: Searching causes Object reference
Hi Wiebe,

If you do not want to search the given type of documents, you can modify the SearchTree query of the document template so that it doesn't return any result, such as this:

SELECT view_cms_tree_joined.*, view_cms_tree_joined.NodeName AS SearchResultName FROM view_cms_tree_joined WHERE 0 = 1

User avatar
Member
Member
wtijsma - 2/8/2005 4:23:13 PM
   
Re: ERROR: Searching causes Object reference
Ok, good enough workaround. The problem is that the default queries get overriden when a field is added or removed, I also noticed this with the stored procedures for standard document templates like cms.news and cms.menuitem).

Would it be an idea to add a 'don't override' property to the queries defined in the CMSDesk to prevent them from being overriden when de document template is altered?

Thanks, Wiebe!

User avatar
Guest
admin - 2/10/2005 9:37:18 AM
   
Re: ERROR: Searching causes Object reference
Hi Wiebe,

Yes, we will try to add it in the nearest versions.

Thank you!