Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gurol Gurkan 3 posts 38 karma points
    May 16, 2013 @ 21:32
    Gurol Gurkan
    0

    Specified cast is not valid on page request

    Umbraco Version: Tried on 6, 6.03, 6.05

    ASP.NET Version:4.0.30319.18034

    Windows: tried on both 2008 R2 and Azure

    SQL Server : Tried on 2012 Express and CE4.

    We seem to be experiencing an undeterministic bug where a page request sometimes gets the following error.

    Refreshing the page usually fixes it, but we can't identify the cause of the problem.

    Has anyone seen this behaviour before? We would appreciate any info regarding where to look.


    In SQL CE: 

     System.Data.SqlServerCe.SqlCeDataReader.GetByte(Int32 ordinal) +84

    In SQL Server Express:

    System.Data.SqlClient.SqlBuffer.get_Byte() +52

    Full Error:

    Server Error in '/' Application.

    ________________________________________

    Specified cast is not valid.

    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: Specified cast is not valid.


    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: Specified cast is not valid.]

       System.Data.SqlClient.SqlBuffer.get_Byte() +52

       umbraco.DataLayer.RecordsReaderAdapter`1.GetByte(String fieldName) +147

       umbraco.cms.businesslogic.macro.MacroProperty.setup() +356

       umbraco.cms.businesslogic.macro.MacroProperty.GetProperties(Int32 MacroId) +314

       umbraco.cms.businesslogic.macro.MacroModel..ctor(Macro m) +232

       umbraco.macro..ctor(String alias) +368

       umbraco.presentation.templateControls.Macro.CreateChildControls() +1323

       System.Web.UI.Control.EnsureChildControls() +189

       System.Web.UI.Control.InitRecursive(Control namingContainer) +186

       System.Web.UI.Control.InitRecursive(Control namingContainer) +421

       System.Web.UI.Control.InitRecursive(Control namingContainer) +421

       System.Web.UI.Control.InitRecursive(Control namingContainer) +421

       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2098



    ________________________________________

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034

  • Doğan Altunbay 1 post 21 karma points
    Jan 20, 2014 @ 13:55
    Doğan Altunbay
    0

    I have also encountered the same problem. Mine is a multisite deployment, and I have not found a solution yet.

  • Mihai Savu 11 posts 75 karma points
    Nov 03, 2014 @ 21:33
    Mihai Savu
    0

    I had the same error after upgrading from 4.7.2 to 7.1.8. On my computer it worked, but on deployment server I got "Specified cast is not valid". The full error log was:


    [17] ERROR Umbraco.Core.UmbracoApplicationBase - [Thread 29] An unhandled exception occurred
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid.
       at System.Data.SqlClient.SqlBuffer.get_Int32()
       at petapoco_factory_5(IDataReader )
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at Umbraco.Core.Persistence.Database.MultiPocoFactory.CallCallback[TRet](Delegate callback, IDataReader dr, Int32 count)
       at Umbraco.Core.Persistence.Database.<>c__DisplayClass1a`1.<CreateMultiPocoFactory>b__19(IDataReader reader, Delegate arg3)
       at Umbraco.Core.Persistence.Database.<Query>d__1c`1.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at Umbraco.Core.Persistence.Repositories.ContentTypeRepository.<PerformGetByQuery>d__f.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
       at Umbraco.Core.Services.ContentTypeService.GetContentType(String alias)
       at Umbraco.Core.Models.PublishedContent.PublishedContentType.CreatePublishedContentType(PublishedItemType itemType, String alias)
       at Umbraco.Core.Cache.CacheProviderExtensions.<>c__DisplayClass9`1.<GetCacheItem>b__8()
       at Umbraco.Core.Cache.StaticCacheProvider.<>c__DisplayClass1a.<GetCacheItem>b__19(String key)
       at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
       at Umbraco.Core.Cache.StaticCacheProvider.GetCacheItem(String cacheKey, Func`1 getCacheItem)
       at Umbraco.Core.Cache.CacheProviderExtensions.GetCacheItem[T](ICacheProvider provider, String cacheKey, Func`1 getCacheItem)
       at Umbraco.Core.Models.PublishedContent.PublishedContentType.Get(PublishedItemType itemType, String alias)
       at Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.Initialize()
       at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.ConvertToDocument(XmlNode xmlNode, Boolean isPreviewing)
       at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.DetermineIdByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Boolean hideTopLevelNode)
       at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Nullable`1 hideTopLevelNode)
       at Umbraco.Web.Routing.ContentFinderByNiceUrl.FindContent(PublishedContentRequest docreq, String route)
       at Umbraco.Web.Routing.ContentFinderByNiceUrl.TryFindContent(PublishedContentRequest docRequest)
       at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
       at Umbraco.Web.Routing.PublishedContentRequestEngine.FindPublishedContent()
       at Umbraco.Web.Routing.PublishedContentRequestEngine.FindPublishedContentAndTemplate()
       at Umbraco.Web.Routing.PublishedContentRequestEngine.PrepareRequest()
       at Umbraco.Web.UmbracoModule.ProcessRequest(HttpContextBase httpContext)
       at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


     
    I suspect the database backup (BAK) from my computer was the problem, but can't tell what it was. I fixed the error by deploying the actual MDF and LDF files from the database. I gave all users Full Control on these two files and then attached them to the SQL Server. The problem was solved.

Please Sign in or register to post replies

Write your reply to:

Draft