Copied to clipboard

Flag this post as spam?

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


  • Dave Brislane 15 posts 46 karma points
    Dec 09, 2011 @ 10:27
    Dave Brislane
    0

    The name 'Library' does not exist in the current context

    Hi All.

    Trying to implement a simple image gallery into one of my sites using Razor and I am getting the error "The name 'Library' does not exist in the current context"  when trying to save or load the Razor script?  I have this script working fine in a WebMatrix Umbraco install I have.  However I cannot get it to work in an existing Umbraco 4.7.0 site that I am running on a hosted virtual server.  Script below:

    @{
        //Check the currentpage has value in the property 'photos'
        if (Model.HasValue("photos"))
        {
            var MediaFolder Library.MediaById(Model.photos);
            
            <div class="flexslider-container">
                <div class="flexslider">
                    <ul class="slides">
                        @foreach (var photo in MediaFolder.Children)
                        {
                            <li>
                                <img src="@photo.umbracoFile" alt="@photo.Name" />
                                <class="flex-caption">@photo.Name</p>
                            </li>
                        }
                    </ul>
                </div>
            </div>
        }
    }

    Any Ideas?

    Many thanks as always.

    Dave.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 09, 2011 @ 10:50
    Dave Woestenborghs
    0

    Do you have the following using directive  in your cshtml file : @using umbraco.MacroEngines ?

  • Dave Brislane 15 posts 46 karma points
    Dec 09, 2011 @ 14:27
    Dave Brislane
    0

    Thanks for the reply dawoe, however even with that @using added I still receive the same error?

     

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 09, 2011 @ 14:32
    Dave Woestenborghs
    0

    On top of your cshtml file you should have this:

    @using umbraco.MacroEngines
    @inherits DynamicNodeContext 

  • Dave Brislane 15 posts 46 karma points
    Dec 09, 2011 @ 14:56
    Dave Brislane
    0

    Still the same issue dawoe even with both statements at the top of my CSHTML files.  Was there something changed/added from 4.7.0 to 4.7.1 to include library.  I can save and execute the scripts without issue from a 4.7.1 build?  I Can't really upgrade the site I need it in though which isn't great.

  • Artem 4 posts 24 karma points
    Dec 09, 2011 @ 16:00
    Artem
    0

    Suppouse referenced post from Razor snippets could help you. There is mention about Library at top.

    Also, instead

    Library.MediaById

    you can use

    Model.MediaById
Please Sign in or register to post replies

Write your reply to:

Draft