Glass Mapper "Unrecognized Guid format" error on MapPropertiesToObject

243 Views Asked by At

I'm getting an error from GlassMapper on certain pages in my Sitecore solution.

    public override void Execute(ObjectConstructionArgs args)
    {
        // check that no other task has created an object and that this is a dynamic object
        if (args.Result != null || args.Configuration.Type.IsAssignableFrom(typeof(IDynamicMetaObjectProvider))) return;

        // create instance using your container
        var obj = ServiceLocator.ServiceProvider.GetService(args.Configuration.Type);

        // map properties from item to model
        args.Configuration.MapPropertiesToObject(obj, args.Service, args.AbstractTypeCreationContext);

        // set the new object as the returned result
        args.Result = obj;
    }

The error is occurring on args.Configuration.MapPropertiesToObject(obj, args.Service, args.AbstractTypeCreationContext); - System.FormatException: Unrecognized Guid format.. This error is only occurring on pages of a particular template, but not ALL pages of that template and I'm not sure how to track down which field is causing the guid error

1

There are 1 best solutions below

0
On

I experienced the same error when a General Link field didn't contain any id="{xxx}" attribute or had it empty like id="". So, I suggest to check the raw value of the link fields on the failing pages.