Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Unable to cast object of type 'System.String' to type

Vote:
 

Hi, 

We using ImageResizer for its focal point feature. It has worked well for us but recently have this error pop up and breaking our site. Our underlying code has not changed, as far as we know so this is a mystery. 

It seems to stem from this class: 

    [MediaDescriptor(ExtensionString = "png,gif,jpg")]
    public partial class ImageFile : BaseImageData, IMedia, IFocalPointData 
    {        
        [BackingType(typeof(PropertyFocalPoint))]
        public virtual FocalPoint FocalPoint { get; set; }

        [ScaffoldColumn(false)]
        public virtual int? OriginalWidth { get; set; }

        [ScaffoldColumn(false)]
        public virtual int? OriginalHeight { get; set; }

    }

Server Error in '/' Application.

Unable to cast object of type 'System.String' to type 'ImageResizer.Plugins.EPiFocalPoint.SpecializedProperties.FocalPoint'.

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.String' to type 'ImageResizer.Plugins.EPiFocalPoint.SpecializedProperties.FocalPoint'.

Source Error:

[No relevant source lines]


Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\abf41fa1\449e8baf\App_global.asax.pbbxxpih.0.cs    Line: 0

Stack Trace:

[InvalidCastException: Unable to cast object of type 'System.String' to type 'ImageResizer.Plugins.EPiFocalPoint.SpecializedProperties.FocalPoint'.]
   EPiServer.DataAbstraction.RuntimeModel.Internal.ContentModelMethods.GetValueOrDefault(PropertyDataCollection propertyDataCollection, String propertyName, Boolean defaultOnIsNull) +111
   Pov.Common.Media.ImageFile_DynamicProxy.MakeReadOnly() +135
   EPiServer.DataAccess.Internal.ContentDB.FinalizeContent(IContent content) +291
   EPiServer.DataAccess.Internal.ContentLoadDB.LoadContentInternal(ContentReference contentLink, Int32 languageBranchId, DbDataReader reader) +1507
   EPiServer.DataAccess.Internal.<>c__DisplayClass4_0.<LoadVersion>b__0() +465
   EPiServer.Data.Providers.Internal.<>c__DisplayClass31_0`1.<Execute>b__0() +58
   EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute(Func`1 method) +70
   EPiServer.Core.<>c__DisplayClass121_0.<LoadContentFromCacheOrRepository>b__0() +35
   EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait(IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy) +1035
   EPiServer.Core.Internal.ContentInstanceCache.ReadThrough(ContentReference contentLink, String selectedLanguage, Func`1 readValue) +107
   EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector) +617
   EPiServer.Core.Internal.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions) +327
   EPiServer.Core.Internal.DefaultContentLoader.TryGet(ContentReference contentLink, LoaderOptions loaderOptions, T& content) +577
   EPiServer.Core.Internal.DefaultContentLoader.Get(ContentReference contentLink, LoaderOptions loaderOptions) +99
   EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.ValidateChangeOfModelType(PropertyDefinitionModel propertyModel, String modelName) +322
   EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.SetStateForPropertyDefinitionModels(ContentTypeModel model) +186
   EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.<AnalyzeProperties>b__15_0(ContentTypeModel model) +67
   System.Threading.Tasks.<>c__DisplayClass17_0`1.<ForWorker>b__1() +1396
   System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) +32
   System.Threading.Tasks.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>) +278

Any help will be much appreciated. 

#251337
Mar 24, 2021 23:27
Vote:
 

Did you recently upgrade the plugin? The problem is on the Dev environment or staging/production as well? Do you think .NET temp files are the issue (try deleting them)

#251429
Edited, Mar 25, 2021 20:46
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.