Copied to clipboard

Flag this post as spam?

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


  • Vishal G.P 62 posts 122 karma points
    Aug 14, 2014 @ 10:00
    Vishal G.P
    0

    Strange GetVortoValue() nullreference Exception

    Hey Guys,

    i just installed vorto 1.2(from Nuget repo) on a existing umbraco 7.1.4 project. I switched a existing textstring property (alias "title") on a doctype to a new vorto textstring property.

    And i call it from code like this.

    <div class="contact-content">
      <h3>@contact.GetPropertyValue("name")</h3>
      @if (contact.HasVortoValue("title")) {                                            
      <span class="job-title">
    @contact.GetVortoValue("title")</span>
    }
    
    
    <a href="tel:@contact.GetPropertyValue("phoneNr")" class="phone">
    @contact.GetPropertyValue("phoneNr")</a>
    </div>
    

    Now the HasVortoValue("title") is true, but when i try to call the contact.GetVortoValue("title") i get a Object reference not set to an instance of an object. See screenshot:

    enter image description here

    The strange thing is that in my debugger if i call the contact.GetPropertyValue("title") i can see that its a Our.Umbraco.Vorto.Models.VortoValue and i can see the values for the different cultures as well. See screen, but when i call the GetVortoValue extension, it fails..

    values are stored in umbraco.config for my node

    <Contact id="1331" parentID="1139" level="3" creatorID="2" sortOrder="4" createDate="2014-08-14T09:22:05" updateDate="2014-08-14T10:07:49" nodeName="TEst" urlName="test" path="-1,1057,1139,1331" isDoc="" nodeType="1142" creatorName="vishalg" writerName="vishalg" writerID="2" template="0" nodeTypeAlias="Contact">
            <name><![CDATA[Test 12]]></name>
            <phoneNr><![CDATA[1234567890]]></phoneNr>
            <email><![CDATA[[email protected]]]></email>
            <media><![CDATA[1207]]></media>
            <title><![CDATA[{"values":{"en-US":"ENG","nl-NL":"NL"},"dtdGuid":"c3c9f565-f7c9-4323-82da-e0623d20b702"}]]></title>
            <test><![CDATA[{"values":{"en-US":"testeb4","nl-NL":"testnl5"},"dtdGuid":"c3c9f565-f7c9-4323-82da-e0623d20b702"}]]></test>
          </Contact>
    

    Am i doing something wrong? enter image description here

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 14, 2014 @ 10:26
    Matt Brailsford
    0

    Hi Vishal,

    It doesn't look like you are doing anything wrong, and from the stack trace, it's not exactly clear where the issue is coming from. The best I could suggest is if you download the source, and debug into the GetPropertValue extension method and see exactly where the error is coming from then we can come up with a workaround.

    Hope this helps.

    Many thanks

    Matt

  • Vishal G.P 62 posts 122 karma points
    Aug 14, 2014 @ 10:56
    Vishal G.P
    0

    Thanks for getting back to me Matt,

    i did that and it fails on a method called CreateDummyProperty()

    enter image description here

    I'm not sure what's happening there. Do you know?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 14, 2014 @ 11:06
    Matt Brailsford
    0

    Hi Vishal,

    What exact version of Umbraco are you using? I'm wondering if it's not new enough and those classes aren't available?

    Many thanks

    Matt

  • Vishal G.P 62 posts 122 karma points
    Aug 14, 2014 @ 11:12
    Vishal G.P
    0

    Hey Matt,

    i'm on Umbraco 7.1.4 , and it looks like you build vorto on 7.1.1.

    Edit: Strange.. i just installed a fresh new 7.1.4 testing with default templates..Installed Vorto from nuget, added a extra culture. And tested the GetVortoValue... and that works without problems..

    I dont hope something is screwed with my current project in the database, cause then i have a problem. :-)

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 14, 2014 @ 12:10
    Matt Brailsford
    0

    Hmm, that should be fine.

    Looking at the YSOD again, it does look like the error is coming from somewhere in the core when it tries to initialize the converters so without being able to step into that code and find the point something is null, I'm not quite sure what to try (given that that code does work some of the time).

    Are you able to debug into the core methods?

    Many thanks

    Matt

  • Vishal G.P 62 posts 122 karma points
    Aug 14, 2014 @ 21:54
    Vishal G.P
    0

    Ok, after hours and hours of debugging and adding the core project to my solution to dig deeper and i think the problem is Vorto in combination with SEO Checker package.

    I created a issue explaining it in detail and to let Richard check if that is really the case..

    I really hope he can help me out quickly. We have a deadline next week and i cannot lose one or both of these packages.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 15, 2014 @ 10:02
    Matt Brailsford
    0

    Hi Vishal,

    I've had a quick look this morning, and may have a workaround (you'll need to make the changes though as it's only a temporary fix and would only be valid for your install). Looking at the PublishedContentType class, it does have one public static method called Get which takes in a PublishedItemType enum and content type alias and returns the matching PublishedContentType, so what you could do is within the CreateDummyProperty, use that method and lookup ANY content type declared in your install (shouldn't matter which one) and pass that through as the first param.

    Like I say, it is a bit of a bandaid, but hopefully it means you can move forward.

    Hope this helps.

    Matt

  • Vishal G.P 62 posts 122 karma points
    Aug 15, 2014 @ 11:33
    Vishal G.P
    0

    Hey Matt,

    thanks for your input, but would you mind helping me out with a little snippet..

    I'm a bit swamped and i would work on this further in the afternoon. So it would really help me to get it up and running quickly..

    thanks alot.. I think we are almost there..

    Vishal

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 15, 2014 @ 11:56
    Matt Brailsford
    1

    Something like the following should work I think:

    private static PublishedPropertyType CreateDummyPropertyType(int dataTypeId, string propertyEditorAlias)
    {
        var contentType = PublishedContentType.Get(PublishedItemType.Content, "THE_ALIAS_TO_ANY_ONE_OF_YOUR_DCOTYPES");
        return new PublishedPropertyType(contentType,
            new PropertyType(new DataTypeDefinition(-1, propertyEditorAlias)
            {
                Id = dataTypeId
            }));
    }
    
  • Vishal G.P 62 posts 122 karma points
    Aug 15, 2014 @ 15:52
    Vishal G.P
    0

    Matt... it works! But an upgrade to SEO-Checker 1.6 also does the trick..

    So i dont need to include the vorto source but can just nuget it into my solution :-)

    This is better, because if you update in the future i can also easily upgrade..

    thanks again for your help..

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 15, 2014 @ 16:29
    Matt Brailsford
    1

    Awesome!

    I'll add it to my list of things to review when I look at vorto next as I have a couple of other things I need to address, but really glad we were able to get you up and running in the mean time.

    Best of luck.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft