Copied to clipboard

Flag this post as spam?

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


  • Damian Green 452 posts 1433 karma points
    Jun 05, 2013 @ 01:16
    Damian Green
    0

    What is missing here when trying to access GetPropertyValue?

    I've just atrted a new project and a clean slate with project setup but got an issue in the extentions project (my project for views etc that i want under source control).

    The umbraco site is v 6.1.1 And i have referenced the Core, cms, umbraco, interfaces, macroengine dll's trying to see if it was something from them and still no joy! :(

    My external project views are not picking up the .GetpropertyValue or AnscestorOrSelf and i assume these are extension methods and I am missing a namespace somewhere.

    The error is:

    'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'GetPropertyValue

    Its probably something missing from the web.config either in the root or the views folder... but what!???

     

  • Damian Green 452 posts 1433 karma points
    Jun 05, 2013 @ 10:54
    Damian Green
    0

    Ok got a bit further with this.

    The extensions are in the Umbraco.Web namespace.  If i import this namespace to the view then it works.  

    @using Umbraco.Web;

    My next question is why is this not getting picked up from the web.config in the views folder as this namespace is added:

     <system.web.webPages.razor>
        <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <pages pageBaseType="System.Web.Mvc.WebViewPage">
          <namespaces>
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="Umbraco.Web" />
            <add namespace="Umbraco.Core" />
            <add namespace="Umbraco.Core.Models" />
            <add namespace="Umbraco.Web.Mvc" />
          </namespaces>
        </pages>
      </system.web.webPages.razor>
  • Damian Green 452 posts 1433 karma points
    Jun 05, 2013 @ 16:45
    Damian Green
    0

    Looked at a few instances of where others having siilar problem with the namespace not importing from the views web.config and some people say resatrting visual studio works and it picks up the namespaces but its not happening in my project.

    Unless i add the namespaces to the individual views it doesnt work correctly.

    Anyone know what the issue is?

     

  • Damian Green 452 posts 1433 karma points
    Jun 05, 2013 @ 17:02
    Damian Green
    100

    Looks like a Visual Stuio bug in intellisense.  Files work ok in Umbraco site - just th eintellisense aint picking it up so to get this working just add the using imports to the top of the View for now.  Pain in the butt but its a workaround.

     

  • Damian Green 452 posts 1433 karma points
    Jun 06, 2013 @ 01:18
    Damian Green
    0

    Just to add - i ended up having other issues with my environment.  Restarting Visual Studio didnt cut it so a full machine restart seems to have fixed everything and i no longer need the namesapce imports in the views! 

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 17, 2013 @ 11:35
    Jeroen Breuer
    0

    Hi Damian,

    I'm having the same problen and a full machine restart also didn't help. Did you find something else which could be the problem? I'm using Visual Studio Express 2012 for Web.

    Jeroen

  • Damian Green 452 posts 1433 karma points
    Jun 17, 2013 @ 13:50
    Damian Green
    0

    Hi Jeroen,

    It was all down to the namespaces and the fact VS wasnt loading them into intellisense when they were declared in the Views web.config.

    First add the namespace imports at the top of the view file - that should give you the intellisense.  At this point i couldnt get my head around why the imports werent getting picked up from the views web config.  This is where a machine restart fixed it and i was able to remove the imports from the views.

    Do you get the intellisense etc when you add the imports at the top of the view?

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 17, 2013 @ 14:41
    Jeroen Breuer
    0

    Yes the intellisense works when I add the imports at the the top. So a machine restart after that should fix it and than I can remove the imports again?

    Jeroen

  • Damian Green 452 posts 1433 karma points
    Jun 17, 2013 @ 16:13
    Damian Green
    0

    It did for me.

    Not had an issue since.  

    As an aside - One project i had I also needed to add in the section declarations used int the views web.config to the base web.config (as i was using a stripped down config) - but you should get an error for this if they weren't in there.

     

Please Sign in or register to post replies

Write your reply to:

Draft