Forum


HomeHomePremiumPremiumDevelopmentDevelopmentIssue with sample codeIssue with sample code
Previous
 
Next
New Post
9/10/2014 5:11 AM
 

I have downloaded and installed the DotNetNuclear.ViewsTutorial code to use with the videos. I am finding the following error after installation of the module on a test page. 

Error: ViewsTutorial is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuclear.Modules.ViewsTutorial.View.rptItemListOnItemDataBound(Object sender, RepeaterItemEventArgs e) in c:\websites\dnndev.me\DesktopModules\DotNetNuclear.ViewsTutorial\View.ascx.cs:line 75 at System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) at DotNetNuclear.Modules.ViewsTutorial.View.BindData() in c:\websites\dnndev.me\DesktopModules\DotNetNuclear.ViewsTutorial\View.ascx.cs:line 62 at DotNetNuclear.Modules.ViewsTutorial.View.Page_Load(Object sender, EventArgs e) in c:\websites\dnndev.me\DesktopModules\DotNetNuclear.ViewsTutorial\View.ascx.cs:line 45 --- End of inner exception stack trace -

The line that is bombing out is in rptItemListOnItemDataBound: Line 75  string sColor = base.Settings["TextColor"].ToString(); 

This is on dnn 7.3.2 and I am using VS 2013 professional on Windows 7 professional x64 / SQLExpress database server 

I have other test modules using the DAL2 template that load properly, so I believe the install is sound. 

Any thoughts are appreciated. 

 
New Post
9/10/2014 9:31 AM
 

So I had to change the code to make it work. base.Settings["TextColor"].ToString() is the source of the fault. It was returning a null which ToString dereferenced. So my question becomes why did this fail? I assume it has been working for others, and I have seen this type of construct used before. Now that there is a TextColor value set via the Settings dialog, the original code is working properly. This started as the example code downloaded an unmodified from the site. Could it be a change in dnn 7.3? 

 

Here is what worked: 

 var bs = base.Settings["TextColor"];

                string sColor;

                if (bs == null)
                {
                    sColor = "#000000";
                }
                else
                {
                    sColor = bs.ToString();
                }

 
New Post
9/11/2014 4:26 AM
 

Kevin,

I'm not sure if there has been a change in 7.3 such that if there is no value for a setting, it returns null.  In most of my new tutorials, I promote using my SettingsRespository class to handle module settings, which ensures proper handling of the setting retrieval and default values.  You can see that in action on my last tutorial on Custom Registration

 
New Post
9/11/2014 9:31 AM
 

Hi Kevin/Scott,

Can you please let me know if you get a notification about this post? I'm trying to troubleshoot some email problems the forum is having.

Thanks,

Aderson

 
New Post
9/11/2014 11:18 AM
 

Aderson,

I did get an email from you but from the wrong post. I received the following in my email which is not what you posted here.

You can view thispost by clickinghere.
Premium
Re: Issue with sample code
by Aderson On 9/11/2014 2:31:57 PM
New post in Development:

Hi Andrian/Scott,

Can you please let me know if you get a notification about this post? I'm trying to troubleshoot some email problems the forum is having.

Thanks,

Aderson


 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentIssue with sample codeIssue with sample code



Try FREE
30 days money back guaranteed