|
|
Rank: Newbie
Joined: 10/2/2006 Posts: 5
|
Hello, I'm writing a custom usercontrol for Umbraco. I need to access to page content. When I try something like: Code:Dim myPage As New umbraco.presentation.nodeFactory.Node(pageId) I get a NullReferenceException error [System.NullReferenceException - Object reference not set to an instance of an object.] The same happens also writing something like this: Code:Dim myPage As New umbraco.presentation.nodeFactory.Node() Any idea? Thanks to all. Lorenzo.
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 597 Location: Bad Homburg, Germany
|
I have no problem with the first code line. So Do you test this running in umbraco? If not this will be your problem. The functions are only availible running in the scope of an umbraco installation. Cheers, Thomas
• 2007/2008 MVP • www.thoehler.com • Bad Homburg, Germany
|
|
Rank: Newbie
Joined: 10/2/2006 Posts: 5
|
Thomas Höhler wrote: I have no problem with the first code line. So Do you test this running in umbraco? If not this will be your problem. The functions are only availible running in the scope of an umbraco installation.
Cheers, Thomas
Thanks for your reply. I simply created a new solution referencing cms, businesslogic and umbraco dlls and created the usercontrol. Web.config replicate exactly the production environment. Importing the resulting dll into umbraco and putting my control in the usercontrols directory, gives the same result. I developed other usercontrols but usually I simply integrate my existing businesslogic into umbraco. This is the first time I need to get umbraco contents. What I'm doing wrong? Thanks. Lorenzo.
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 597 Location: Bad Homburg, Germany
|
Ok I don't know your configuration. So I did my own usercontrol to get all informations via umbraco.presentation. Something like that: Code: Dim n As new umbraco.presentation.nodeFactory.Node(nodeID) Me.lblMessage.Text = "Nodename: " + n.Name For Each p As umbraco.presentation.nodeFactory.Property In n.Properties Me.lblMessage.Text += "<br/>Property '" + p.Alias + "': " + p.Value next
You can get the dll and the ascx here: http://www.diehoehlers.de/media/432/getnode.zipThe complete project here: http://www.diehoehlers.de/media/429/th.zipTry this. If this doesn't work it must something other. Then you can get a complete information via adding ?umbDebugShowTrace=true to the end of your URL. hth, Thomas
• 2007/2008 MVP • www.thoehler.com • Bad Homburg, Germany
|
|
Rank: Newbie
Joined: 10/2/2006 Posts: 5
|
Thank you for your help. I putted your usercontrol in usercontrols directory. I putted your dll in bin directory. I created the macro 'test'. I putted the macro on a page. Now I'm getting the following error: Code:renderMacro Rendering started (macro: Test, type: 3, cacheRate: 0) 0.010988 0.000033 umbracoMacro Usercontrol added (UserControls/GetNode.ascx) 0.011034 0.000046 macro Error creating usercontrol (UserControls/GetNode.ascx) Parser Error: Could not load type 'th.umbracotest.GetNode'. at System.Web.UI.TemplateParser.ParseString(String text, String virtualPath, String basePhysicalDir) at System.Web.UI.TemplateParser.ParseFile(String filename, String virtualPath) at System.Web.UI.TemplateParser.Parse() at System.Web.UI.TemplateParser.GetParserCacheItemThroughCompilation() at System.Web.UI.TemplateParser.GetParserCacheItemInternal(Boolean fCreateIfNotFound) at System.Web.UI.TemplateParser.GetParserCacheItemWithNewConfigPath() at System.Web.UI.TemplateParser.GetParserCacheItem() at System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.TemplateControlParser.GetCompiledType(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.UserControlParser.GetCompiledUserControlType(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.TemplateControl.LoadControl(String virtualPath) at umbraco.macro.loadUserControl(String fileName, Hashtable attributes, page umbPage) 0.012450 0.001416 Note that after a IIS restart, trace on first application request discover these two errors: Code:datatype.Factory Couldn't load C:\Inetpub\wwwroot\www.tiramisu.com\bin\th.umbracotest.dll 0.334738 0.001484 datatype.factory Reading assembly C:\Inetpub\wwwroot\www.tiramisu.com\bin\TidyDll.dll 0.334803 0.000065 datatype.Factory Couldn't load C:\Inetpub\wwwroot\www.tiramisu.com\bin\TidyDll.dll Now before test your nodeFactory code I have solve this new issue :hmm: :) Lorenzo.
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 597 Location: Bad Homburg, Germany
|
The dll is made with .net 2.0. Are you using .Net 1.1? Thomas
• 2007/2008 MVP • www.thoehler.com • Bad Homburg, Germany
|
|
Rank: Newbie
Joined: 10/2/2006 Posts: 5
|
Yes, I use Framework 1.1. I have installed your dll as you send me on Umbraco 2.1.4 which is compiled under .NET 1.1.
Lorenzo.
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 597 Location: Bad Homburg, Germany
|
|
|
Rank: Newbie
Joined: 10/2/2006 Posts: 5
|
Now all it's ok.:w00t:
Thank you. Lorenzo.
|
|
|
Guest |