Will "the Mighty" Strohl

ERROR: Object Reference Not Set to an Instance of an Object

First of all, it is not a recommended practice to modify any of the Core DNN files, including the install and upgrade packages.  Anyhow, I did.  This was to take advantage of the auto-install capability and automatically install some of our modules and skins.

Well, due to some problems that were encountered during the attempted install of the DNN portal, I ended up removing the custom modules and skins.  The good thing is that the install went without a flaw this time.  However, I kept getting this error when I attempted to view any page in the web site.

When I enabled the site to compile into debug mode, and tried to view the page again, it told me that the offending line of code was this:

ctlSkin.ID = "dnn"

Well, this perplexed me, since this is a part of the core code, and it obviously has been thoroughly tested.  So, I could only conclude that it was something I had done.

This is where we take a trip into Troubleshooting 101.  I then began to look at the lines of code just before this one.  More specifically, I looked at where ctlSkin was instantiated/dimmed and what happened to it afterward, up until the errored line.

To begin, this object is meant to hold a reference to the skin mechanism that is part of DNN and renders your skin over your page and modules.  First and foremost, it looks to see if there is a skin override contained in the URL querystring parameters. 

Then, it checks to see if there is an override in a cookie - but only if the querystring didn't populate the skin object.

Next, it checks to see if the page or site is assigned a skin.  If so, it uses this skin reference - but again, only if it was not previously populated.

Finally, if those steps did not prove to populate the skin object, it attempts to load the default skin into the skin object.  As we all know, this is the DNN-Blue skin that comes preinstalled on DNN.

Following that final attempt to load the skin object, we then have the line that attempts to reference the ID property of the skin object.  Since we get the aforementioned error, we can be confident that the skin object was not successfully instantiated through any of the previous attempts.

This could only mean one thing.  First, I didn't append a reference to the skin in the URL.  Second, I did not have a cookie to tell the site which skin to use.  Third, the page/site had no reference to the skin yet, because we hadn't even been able to see a page yet.  That would leave only one way for the skin object to get loaded - the default. 

If the default didn't load the skin, then the default could not be found.  I dashed for the skins directory...


Low and behold, the skins folders were missing.  I had not installed a skin somehow.  Luckilly, I am pretty familiar with the skin installation logic.  All you have to do is copy over a previous rendered/installed skin package from another web site, and you're fixed!

I hope you enjoyed my momentary lapse in judgement.

blog comments powered by Disqus