Object reference not set to an instance of an object.

Posted by Community Admin on 04-Aug-2018 16:38

Object reference not set to an instance of an object.

All Replies

Posted by Community Admin on 19-Jan-2011 00:00

Hi,

I am Vikas and presently evaluating sitefinity 4.0. We want to upgrade our current sitefinity version to 4.0 version. I have installed framework 4.0 on my server and deployed sitefinity project on this server. After deployment I see object reference not set to instance of the object error. I tried my best to solve it but couldn't able to figure this out.  You can also access the site using the following url for your reference
http://94.236.101.19/proxiobeta/sitefinity

Please help me in this regard this will help us to evaluate faster. I thank you for your help in advance.


Best regards,
Vikas

Posted by Community Admin on 19-Jan-2011 00:00

I did more investigation and found that this is giving following error

Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'Telerik.Sitefinity.Security.SitefinityPrincipal'


You can use the following userid and password for the admin section to verify

username: admin
password: admin12345


Please help.

Posted by Community Admin on 25-Jan-2011 00:00

Hello Vikas,

Could you please let us know what kind of authentication are you using? We haven't checked the web site yet. If you are trying to use the standard membership providers, this is not possible at the moment. We will provide support for this in the Q1 release.

All the best,
Georgi
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 19-Aug-2011 00:00

Hi all,

we're getting this error intermittently now that we're running 4.2. I wish I could say that I could reproduce it regularly, but I can't.

Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'Telerik.Sitefinity.Security.SitefinityPrincipal'.
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.InvalidCastException: Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'Telerik.Sitefinity.Security.SitefinityPrincipal'.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 
 
[InvalidCastException: Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'Telerik.Sitefinity.Security.SitefinityPrincipal'.]
   Telerik.Sitefinity.Web.SiteMapBase.IsAccessibleToUser(HttpContext context, SiteMapNode node) +232
   Telerik.Sitefinity.Web.SitefinitySiteMap.IsAccessibleToUser(HttpContext context, SiteMapNode node) +67
   System.Web.SiteMapNode.IsAccessibleToUser(HttpContext context) +17
   Telerik.Sitefinity.Web.SitefinityRoute.CheckSecurity(HttpContextBase httpContext, PageSiteNode node) +53
   Telerik.Sitefinity.Web.SitefinityRoute.GetRouteData(HttpContextBase httpContext) +640
   System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +287
   System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +60
   System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +86
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


We are using a custom role provider:

<roleManager enabled="true" defaultProvider="Aptify">
  <providers>
    <clear/>
    <add aptifyServer="srv-sql-dev" aptifyTrusted="true" aptifyDb="Aptify" name="Aptify" aptifyWebUserID="11" type="OSCPA.Web.Providers.AptifyRoleProvider, OSCPA.Web.Providers"/>
  </providers>
</roleManager>

I can try to provide you any additional information you require.
Joel

Posted by Community Admin on 23-Aug-2011 00:00

Hi Joel,

Could you try removing the following attribute:

defaultProvider="Aptify"

Best wishes,
Lubomir Velkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 23-Aug-2011 00:00

I'm not sure that was all I needed to remove: I'm <clear>'ing the list of role providers before I add mine.

Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Default Role Provider could not be found.

Source Error:

Line 71:       </providers>
Line 72:     </siteMap>
Line 73:     <roleManager enabled="true" >
Line 74:       <providers>
Line 75:         <clear/>


Posted by Community Admin on 26-Aug-2011 00:00

Hi Joel,

What is exact version of Sitefinity that you use? We fixed an issue with the custom Role provider in Sitefinity 4.1. Back in 4.0 this was still an issue and was not supported. If you use an older version of Sitefinity, please upgrade.

All the best,
Lubomir Velkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 26-Aug-2011 00:00

Hi Lubomir,

We are running 4.2.1650.0.

I'm sorry, I wish I had better information for you. There doesn't seem to be any reason that these exceptions are thrown, however, clearing cookies seems to correct the problem.

Thank you for your time!
Joel

Posted by Community Admin on 26-Aug-2011 00:00

Hi Joel,

I'm glad that you solved your issue. I suppose you upgraded to 4.2 from some older version and there were some old cookies left in your browser that caused the problem.

Best wishes,
Lubomir Velkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 26-Aug-2011 00:00

Hey Lumbomir,

Is there any chance to find out why it's happening? I know clearing cookies can be a work-around, but my main goal is not to frustrate my customers. Is there anything that I could wrap in a try...catch to suppress this error?

Thanks!
Joel

Posted by Community Admin on 29-Aug-2011 00:00

Hello Joel,

The cookie contains information for the logged principal. Prior to version 4.1 we couldn't support ASP.NET Role providers because of a bug that was overriding our SitefinityPrincipal with a RolePrincipal. We fixed this in 4.1 so it switches the RolePrincipal with our SitefinityPrincipal. But it seems that you were logged in before upgrading and the old RolePrincipal was serialized in the cookie, so after the upgrade you were considered logged in with the RolePrincipal, while the 4.1 was expecting to have a SitefinityPrincipal. This is why deleting the cookie resulted in its recreation as SitefinityPrincipal and now everything works.

All the best,
Lubomir Velkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 09-Sep-2011 00:00

We are using Sitefinity 4.2.1650.0  with a custom roleprovider and this is still an issue

When the roleprovider is disabled in the web.config file the logged in user has access to authenticated pages

HOWEVER the custom roles are NOT available in the backend for use in permissioning content.

When the roleprovider is enabled, a page that requires the user to be authenticated FALLS OVER with this error
BUT the roles ARE NOW available in the backend for permissioning purposes

Do you have a fix for this ?


Posted by Community Admin on 14-Sep-2011 00:00

Hello Sonia,

You need to have the role provider enabled in the web.config, otherwise the roles won't be available in your backend. I wasn't able to load your site - it took way too much time, could you please check it so I can see what is going on.

Greetings,
Lubomir Velkov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 14-Sep-2011 00:00

The problem is caused by calling your SecurityManager.AuthenticateUser in the context.AuthenticateRequest event 

It does not fall over if called in the PostAuthenticateRequest event

This was all done housed in a HttpModule

However getting context.PostAuthenticateRequest to reliably fire on each request is another problem ... however we've got around this.

Posted by Community Admin on 16-Sep-2011 00:00

Hello Sonia,

So did you manage to get a workaround for this problem? Anything more we could do to help you?

All the best,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 18-Jan-2012 00:00

I have same problem.
Did somebody got  solution?

Posted by Community Admin on 19-Jan-2012 00:00

Hello Kairat,

Since there are several participants in this thread and everyone seems to have different issues, could you please explain in more details what is excatly your issue?

Greetings,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed