Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'Kaliko CMS.Core.PropertyData'.

47 views
Skip to first unread message

Sean Gadsby

unread,
Nov 17, 2020, 6:26:12 PM11/17/20
to KalikoCMS Developer Forum
I created a Selector Factory:
 public class RobotsMethodsFactory : SelectorFactory<string>
    {
        public override IEnumerable<SelectorItem<string>> Options =>
            new List<SelectorItem<string>>()
            {
                new SelectorItem<string>() { Value = "index", Title = "Index"/*, Description = "Tells a search engine to index a page."*/},
                new SelectorItem<string>() { Value = "noindex", Title = "NoIndex"/*, Description = "Tells a search engine not to index a page."*/},
                new SelectorItem<string>() { Value = "follow", Title = "Follow"/*, Description = "Even if the page isn’t indexed, the crawler should follow all the links on a page and pass equity to the linked pages."*/},
                new SelectorItem<string>() { Value = "nofollow", Title = "NoFollow"/*, Description = "Tells a crawler not to follow any links on a page or pass along any link equity."*/},
                new SelectorItem<string>() { Value = "noimageindex", Title = "NoImageIndex"/*, Description = "Tells a crawler not to index any images on a page."*/},
                new SelectorItem<string>() { Value = "none", Title = "None"/*, Description = "Equivalent to using both the NoIndex and NoFollow tags simultaneously."*/},
                new SelectorItem<string>() { Value = "noarchive", Title = "NoArchive"/*, Description = "Search engines should not show a cached link to this page on a SERP."*/},
                new SelectorItem<string>() { Value = "nocache", Title = "NoCache"/*, Description = "Same as NoArchive, but only used by Internet Explorer and Firefox."*/},
                new SelectorItem<string>() { Value = "nosnippet", Title = "NoSnippet"/*, Description = "Tells a search engine not to show a snippet of this page (i.e. meta description) of this page on a SERP."*/},
                new SelectorItem<string>() { Value = "unavailable_after", Title = "Unavailable_After"/*, Description = "Search engines should no longer index this page after a particular date."*/}
            };
    }

But when I use the selector factory:
[SelectorProperty("Robots" , selectorFactory:typeof(RobotsMethodsFactory), TabGroup = "Search Engine Optimization")]
        public virtual SelectorProperty<string> Robots { get; set; }

I get the error "Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'Kaliko CMS.Core.PropertyData'."

Anyone else encountered this, and what am I doing wrong?

Fredrik Schultz

unread,
Nov 18, 2020, 2:32:36 PM11/18/20
to KalikoCMS Developer Forum
Hi,
I'm not sure why you get a cast error. I've tested your code in the demo project and it worked as it should.

What version are you using of the CMS and Newtonsoft.Json? Is the Robots property placed directly in a page type (or something like a custom property type)? Do you have any custom settings for Newtonsoft.Json in your project?


Sean Gadsby

unread,
Nov 18, 2020, 3:00:44 PM11/18/20
to KalikoCMS Developer Forum
CMS Version 1.2.5.0 - using MVC, SQL and Identity.
NewtonSoft.Json Version 11.0.0.0 as installed by CMS.  No Custom Setting.

The property is in a page type.

In the project at the moment, there is one page type and Controller, View.

I'm just trying an update of all the package to the latest versions.

Sean Gadsby

unread,
Nov 18, 2020, 3:07:03 PM11/18/20
to KalikoCMS Developer Forum
That didn't work so have reverted back.

Fredrik Schultz

unread,
Nov 21, 2020, 3:42:28 PM11/21/20
to KalikoCMS Developer Forum
I've tried to downgrade but can't recreate the error. Will send you an email for further troubleshooting.
Reply all
Reply to author
Forward
0 new messages