Copied to clipboard

Flag this post as spam?

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


  • Dima Stefantsov 100 posts 225 karma points
    Apr 14, 2013 @ 12:50
    Dima Stefantsov
    0

    'umbraco.interfaces.INode' does not contain a definition for 'GetCurrent'

    Hi. I'm having problems with understanding what's going on in my 6.0.3 umbraco.

    Here is the code in some Razor macro:

    @using umbraco.NodeFactory
    @{
       var qwe = Node.GetCurrent();
    }

    I'm getting exception: error CS1061: 'umbraco.interfaces.INode' does not contain a definition for 'GetCurrent' and no extension method 'GetCurrent' accepting a first argument of type 'umbraco.interfaces.INode' could be found (are you missing a using directive or an assembly reference?)

    When I type it as
    var qwe = umbraco.NodeFactory.Node.GetCurrent();
    everything works fine. I am wondering, what is going on? Why when I do not specify parent namespace for Node, it's answering me like it's INode?
  • Charles Afford 1163 posts 1709 karma points
    Apr 14, 2013 @ 14:03
    Charles Afford
    0

    Thats strange :/.  What other using statements do you have?  You should be using Node node and not var.  :)

     

  • Dima Stefantsov 100 posts 225 karma points
    Apr 14, 2013 @ 14:23
    Dima Stefantsov
    0

    var is never used to guess variable type. Vice versa, it's resolved into the type when compiling to IL code. I have just tried Node qwe = ... , it changed nothing =)

    Here are all usings:
    @using UCommerce.Api
    @using UCommerce.EntitiesV2
    @using UCommerce.Extensions
    @using UCommerce.RazorStore.Code.Shop
    @using UCommerce.Runtime
    @using umbraco.NodeFactory

    But it should not matter, because I have tried it this way: once I remove single using line of umbraco.NodeFactory, I'm getting error: 'umbraco.MacroEngines.BaseContext<T>.Node' is a 'property' but is used like a 'type'.

  • Charles Afford 1163 posts 1709 karma points
    Apr 14, 2013 @ 14:48
    Charles Afford
    0

    Strange and yes it should not matter.  Have you tried removing the UCommerce refrences  Would be intrested to hear of the solution if and when you find it :).  Charlie  

  • Dima Stefantsov 100 posts 225 karma points
    Apr 14, 2013 @ 14:53
    Dima Stefantsov
    0

    Removed all usings except umbraco.NodeFactory, nothing changed.

  • Charles Afford 1163 posts 1709 karma points
    Apr 14, 2013 @ 21:31
    Charles Afford
    0

    Not totally sure what the problem is :(.  I will have a think.  The main thing at the moment is you can still use it i guess.   If you do find out please let me know :).  Chalrlie

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Apr 17, 2013 @ 10:56
    Tim
    0

    If you're using a razor macro in v6, you don't need to use the Node API, you can just use @Model.Content for a strongly typed content object with intellisense or for a dynamic version, just use @CurrentPage.

    Hope that helps!

  • Dima Stefantsov 100 posts 225 karma points
    Apr 17, 2013 @ 11:57
    Dima Stefantsov
    0

    I don't know if that's "razor macro" I'm using. It's .cshtml file, located in macroScripts folder, it have a couple of usings and razor markup. In umbraco backend it's in "or script file". In my umbraco settings there's <defaultRenderingEngine>WebForms</defaultRenderingEngine>.

    Model have no intellisense in my vs2012. "The name 'CurrentPage' does not exist in the current context", Model.Content gives me.. some variable with text of the main page. If trying to use it instead of var current = umbraco.NodeFactory.Node.GetCurrent();, I'm getting Exception: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'System.Web.HtmlString' does not contain a definition for 'Id'.

    Anyway I'm not sure if it's relevant to the topic: why is Node class when referenced without namespaces, acting like it's INode interface? Must be some magic going on.

  • Charles Afford 1163 posts 1709 karma points
    Apr 17, 2013 @ 15:25
    Charles Afford
    0

    Right, there lies one problem.  What version of umbraco are you using.  And where and what is the macro scripts folder?  If you are using a .cshtml file.  Then  you need to change <defaultRenderingEngine>WebForms</defaultRenderingEngine>. to <defaultRenderingEngine>MVC</defaultRenderingEngine>.

    In the dll for you project you need to add the umbraco DLLS, found in the bin of the package. Namely Umbraco.dll. This will have the umbraco.nodefactory namespace :). Charlie :)

  • Charles Afford 1163 posts 1709 karma points
    Apr 17, 2013 @ 15:27
    Charles Afford
    0

    At the very top of your razor file use 

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    and then you can do

    @Model.Content.GetProperty ... ect ect ect

  • Dima Stefantsov 100 posts 225 karma points
    Apr 17, 2013 @ 18:33
    Dima Stefantsov
    0

    Like I said in the first post, it's Umbraco 6.0.3. MacroScripts folder is the default one. The one placed in the root of the Umbraco. The one Umbraco is looking for script files for category "or script file". Let's try to be clear: webforms and mvc are different paradigms of programming. Razor, aspx, xslt etc. is markup language, the way to tell compiler what to do. Nothing wrong in coding MVC views in aspx. Actually when Razor markup was very new, MVC used to use aspx views, if I'm not mistaken. As far as I understand, defaultRenderingEngine parameter is in charge of setting default Umbraco templating system. If it's MVC, new templates you create in Umbraco are "views", not webforms pages. You are telling me to use @inherits Umbraco.Web.Mvc.UmbracoTemplatePage in my macro. First of all my project doesn't know the .Mvc namespace part (what dll should I include?) Second thought: my .cshtml file is not umbraco template page! It's not mvc view! It's a macro. A Razor macro from macroScripts folder. I don't think we are heading in right direction at all. Have a look at http://our.umbraco.org/projects/website-utilities/ucommerce , the file I particulary talking about is ~\macroScripts\uCommerce\LeftNavigation.cshtml

    >> In the dll for you project you need to add the umbraco DLLS, found in the bin of the package. Namely Umbraco.dll. This will have the umbraco.nodefactory namespace :). Charlie :)

    I already have it referenced. That's why I'm able to see umbraco. NodeFactory namespace in my IntelliSense. It doesn't matter for the runtime, though, as by default .cshtml files are not compiled. Take a look at https://bitbucket.org/uCommerce/ucommerce-razor-store , I'm using this visual studio solution. It doesn't matter, though. I just have default .cshtml macro in default macro folder. It's using default umbraco.NodeFactory.Node, and for some reason INode interface is popping somewhere there inbetween. What is happening? - is the question.

  • Charles Afford 1163 posts 1709 karma points
    Apr 18, 2013 @ 10:06
    Charles Afford
    1

    OK!  I have not seen the macro scripts folder but will take a look.  Hope you find a solution.  Good luck :).  Charlie

  • Dima Stefantsov 100 posts 225 karma points
    Apr 18, 2013 @ 12:22
    Dima Stefantsov
    0

    Thank you, Charlie =)

  • Morten Skjoldager 440 posts 1499 karma points
    Apr 19, 2013 @ 13:10
    Morten Skjoldager
    0

    Hi Dima. Did you find a solution to this?

     

    I just tried adding a clean umbraco 6.0.3 site and get the same error. So no uCommerce related issues here.

    However it seems that it has some ambigous reference without really having it anyways. Very strange indeed. 

    Try removing your references to Umbraco and adding them again. I added a test project and added the references. It worked fine in that project. 

  • Dima Stefantsov 100 posts 225 karma points
    Apr 19, 2013 @ 13:28
    Dima Stefantsov
    0

    Hi Morten. Where should I delete references from? I'm adding new test.cshtml to \macroScripts , it's content is 

    @using umbraco.NodeFactory
    @{
        //var current = umbraco.NodeFactory.Node.GetCurrent();
        var current = Node.GetCurrent();
    }

    @current.ToString()

    And it is already getting same exception. Razorstore project references are just for convenience when it comes to .cshtml.

    It's totally the same on empty 6.1.0-beta Umbraco with just starter kit installed. Clearly not an issue with uCommerce.

    Can you please elaborate on how you was able to _use_ var current = Node.GetCurrent(); ? (intellisense always used to say it's fine; runtime is different story)

  • Morten Skjoldager 440 posts 1499 karma points
    Apr 19, 2013 @ 13:47
    Morten Skjoldager
    0

    Dima,

    I meant a Testproject as in MSTest :) 

    The nuget package might do some strange stuff witht the references that it shouldn't do. However it is a wild guess. 

    Remove the reference to Umbraco in your web project and add it again. After doing so i got it working. Dunno what conflicted though.

  • Dima Stefantsov 100 posts 225 karma points
    Apr 19, 2013 @ 13:54
    Dima Stefantsov
    0

    Hm, I'm not using Visual Studio, or nuget for Umbraco. I just download it from codeplex, and throw it to webmatrix or IIS. And it doesn't have any "references". It just uses whatever it can find in /bin afaik. (maybe have something to do with web.config as well)

    So you are saying that in bare console/text VS solution umbraco.NodeFactory library is working as expected. Good to hear.

    But what is happening in Umbraco Macro? :)

  • Dima Stefantsov 100 posts 225 karma points
    Apr 19, 2013 @ 17:03
    Dima Stefantsov
    0

    Here is what happening: even though I do not write it, looks like Macro is automatically inherited from umbraco.MacroEngines.DynamicNodeContext (or from some other class, that's a child to BaseContext<>). This is a guess, but it sounds pretty much right.

    This class have property named Node:

       public INode Node
        {
          get
          {
            return this._node;
          }
        }

    VoilĂ !

Please Sign in or register to post replies

Write your reply to:

Draft