Bug reports Found a bug? Post it here please.
Version 7.x > Bug reports > VariantSlider.get_VariantMode() -> Object reference not set to an instance of an object. View modes: 
User avatar
Member
Member
Guenter - 1/31/2014 5:28:13 AM
   
VariantSlider.get_VariantMode() -> Object reference not set to an instance of an object.
Hi,

I get an exception when executing a custom webpart. What can be the cause for this?
Message: Object reference not set to an instance of an object. 
Stack Trace:
at CMSModules_OnlineMarketing_Controls_Content_VariantSlider.get_VariantMode() in \CMSModules\OnlineMarketing\Controls\Content\VariantSlider.ascx.cs:line 159
at CMSModules_OnlineMarketing_Controls_Content_VariantSlider.CheckPermissions(String permissionName) in \CMSModules\OnlineMarketing\Controls\Content\VariantSlider.ascx.cs:line 180
at CMSModules_OnlineMarketing_Controls_Content_VariantSlider.OnInit(EventArgs e) in \CMSModules\OnlineMarketing\Controls\Content\VariantSlider.ascx.cs:line 209
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at CMS.PortalControls.CMSAbstractWebPart.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The custom webpart itself tries to check a user permission like this:
CMSContext.CurrentUser.IsAuthorizedPerResource(resourceName, permission.ToString());

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 2/3/2014 10:01:37 AM
   
RE:VariantSlider.get_VariantMode() -> Object reference not set to an instance of an object.
Hello Guenter,

As this is your custom WebPart and this is a general .NET error, try to search the Google for possible reasons a debug your web part, so you will be able to see what is stored in the variables at the execution time. It seems that something in your code is not initialized.

Best Regards,
Martin Danko

User avatar
Member
Member
Guenter - 2/4/2014 4:45:36 AM
   
RE:VariantSlider.get_VariantMode() -> Object reference not set to an instance of an object.
Thank you for your answer!

The exception is a general .NET exception, but it's occuring in CMSModules_OnlineMarketing_Controls_Content_VariantSlider.get_VariantMode() which is Kentico Module. Since this Kentico module is obviously the cause of the error, I'm not quite happy with your answer.

Could you give me some hints about this VariantSlider control? What could be the reason so that this Kentico control gives this error?

User avatar
Member
Member
Guenter - 2/5/2014 4:36:00 AM
   
RE:VariantSlider.get_VariantMode() -> Object reference not set to an instance of an object.
Problem solved. Thanks.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 2/12/2014 2:54:02 AM
   
RE:VariantSlider.get_VariantMode() -> Object reference not set to an instance of an object.
Hi Gaunter,

if you will have time, it will be great if you can provide other users with the solution. It's possible that somebody will experience the same issue in the past.

Thank you!

Best Regards,
Martin Danko