Sitecore tells you: “Specified cast is not valid” during startup

An annoying issue which came across twice this week: Sitecore was throwing “Specified cast is not valid”-Exceptions:

"Specified Cast is not valid"-exception

And seriously, if there’s one thing I hate about .NET in general, it are exceptions. 95% of the time they are non self explaining and sometimes even nonsense. This exception would normally take me 20 minutes to solve at least. But not this time. So how to solve this one?

Basically, this is nothing more than a Database Connection error… When I added /sitecore behind my url, I received a generic connection failure exception. I had to do some work on my connection string(or start my SQL Server). That’s all. But Alex, where did it come from? And why does the login page show something different?

Chicken and the egg issue: when accessing an Item we need a (SQL)-Database, but before allowing to access an Item, we need a User, a User needs a (SQL)-Database. And of course, this dependancy became stronger when we introduced Sitecore v6 with the Membership Providers.

So what can we learn from this? Always consult both pages: / and /sitecore. Often, there’s a different message. Sitecore is all based on context(yes, Sitecore.Context…). So when you have a problem, always try different entry points to minimize the Context. For example, Sitecore has by default 2 active websites running: ‘website’ and ‘shell’. In this case, I tried to access both of them.

Happy coding out there 🙂

4 thoughts on “Sitecore tells you: “Specified cast is not valid” during startup”

  1. Hi Alex,
    I am having an issue with sitecore when I try to create something through C#.net code in sitecore.The issue is:
    Specified cast is not valid. at Sitecore.Security.UserProfile.get_IsAdministrator()
    at Sitecore.Security.AccessControl.SqlAuthorizationProvider.GetSpecialAccess(ISecurable entity, Account account, AccessRight accessRight)
    at Sitecore.Security.AccessControl.SqlAuthorizationProvider.GetAccessCore(ISecurable entity, Account account, AccessRight accessRight)
    at Sitecore.Security.AccessControl.AuthorizationProvider.GetAccess(ISecurable entity, Account account, AccessRight accessRight)
    at Sitecore.Security.AccessControl.AuthorizationManager.GetAccess(ISecurable entity, Account account, AccessRight accessRight)
    at Sitecore.Security.AccessControl.AuthorizationManager.IsAllowed(ISecurable entity, AccessRight right, Account account)
    at Sitecore.Security.AccessControl.ItemAccess.CanCreate()
    at Sitecore.Data.Managers.ItemProvider.AddFromTemplate(String itemName, ID templateId, Item destination, ID newId)
    at Sitecore.Data.Managers.ItemManager.AddFromTemplate(Strin]
    Could you please help me to resolve this issue?

  2. Flash web designers will like the cost and the creativity of the Trendy Flash Site Builder.
    You might get one or more benefits of outline designer along
    with it is the ideal means to unleash the capacities.
    We saw earlier that we could, through links to email addresses, contact directly with an email.

Comments are closed.