Helpers does not exist in the namespace 'Microsoft.Web
Hi,
I am having trouble upgrading an existing Umbraco site v7.2 to v7.5, in particular, a gallery page which renders different folders from the media library of images here is the code:
@{
//Check the currentpage has a value in the property 'photos'
if (Model.HasValue("photos"))
{
var MediaFolder = Library.MediaById(Model.photos);
<ul class="clearing-thumbs" data-clearing>
@foreach (var photo in MediaFolder.Children)
{
<li>
<a class="th" href="/[email protected]" rel="gallery"><img src="/[email protected]&width=146&height=112&constrain=true&crop=resize&align=center&altImage=/img/no-image.png" alt="@photo.Name"/></a>
</li>
}
</ul>
}
}
The page errors with this CS0234: The type or namespace name 'Helpers'
does not exist in the namespace 'Microsoft.Web' (are you missing an
assembly reference?)
Now I've searched a few forums which suggest adding back in the Microst.Web.Helpers dll file. but all this does is make the whole site error with this:
Attempt by security transparent method
'Microsoft.Web.Helpers.PreApplicationStartCode.Start()' to access
security critical method
'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)'
failed.
I am well and truly stuck if anybody could help me would be much appreciated.
This is the only piece of code that breaks the site here http://dev.greenovalgarage.co.uk/gallery/ , I've tried removing the code bit by bit but no joy, if I remove the code altogether the page renders but without the gallery images.
Here is the gallery code, although the main image isn't being rendered, which could be part of the problem:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
foreach (var gallery in CurrentPage.Children)
{
if (gallery.HasValue("photos"))
{
var MediaGalleryFolder = Umbraco.Media((int)gallery.galleryImage);
var noPhotos = MediaGalleryFolder.Children.Count();
//Get the first image in the folder
var imageNode = MediaGalleryFolder.Children.First();
var imageURL = imageNode.umbracoFile;
CS1928: 'Umbraco.Web.Models.PartialViewMacroModel' does not contain a definition for 'HasValue' and the best extension method overload 'Umbraco.Web.PublishedContentExtensions.HasValue(Umbraco.Core.Models.IPublishedContent, string)' has some invalid arguments
Hi Dave, Thanks for your patience on this. So the first bit of code yesterday essential chooses a media folder with images in and displays the first image, and this works great now thanks to you, http://dev.greenovalgarage.co.uk/gallery/ and click on the gallery images.
The second piece of good basically displays the remaining images within that folder on a separate page this is the code:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
//Check the currentpage has a value in the property 'photos'
if (Model.HasValue("photos"))
{
var MediaFolder = Model.MediaById(Model.photos);
<ul class="clearing-thumbs" data-clearing>
@foreach (var photo in MediaFolder.Children)
{
<li>
<a class="th" href="/ImageGen.ashx? [email protected]" rel="gallery"><img src="/[email protected]&width=146&height=112&constrain=true&crop=resize&align=center&altImage=/img/no-image.png" alt="@photo.Name"/></a>
</li>
}
</ul>
}
}
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
//Check the currentpage has a value in the property 'photos'
if (Model.Content.HasValue("photos"))
{
var MediaFolder = this.Umbraco.TypedMedia(Model.Content.GetPropertyValue<int>("photos"));
<ul class="clearing-thumbs" data-clearing>
@foreach (var photo in MediaFolder.Children)
{
var url = photo.GetPropertyValue<string>("umbracoFile");
<li>
<a class="th" href="/ImageGen.ashx? image=@url" rel="gallery"><img src="/ImageGen.ashx?image=@url&width=146&height=112&constrain=true&crop=resize&align=center&altImage=/img/no-image.png" alt="@photo.Name" /></a>
</li>
}
</ul>
}
}
Helpers does not exist in the namespace 'Microsoft.Web
Hi,
I am having trouble upgrading an existing Umbraco site v7.2 to v7.5, in particular, a gallery page which renders different folders from the media library of images here is the code:
}
Now I've searched a few forums which suggest adding back in the Microst.Web.Helpers dll file. but all this does is make the whole site error with this:
Attempt by security transparent method
I am well and truly stuck if anybody could help me would be much appreciated.
Kind Regards
Nick
Hi Nick,
Don't see any code that should need this library. Is it only this view or are there other views that have this issue as well.
Have you tried removing the code from the view or and adding pieces one by one.
This usually helps me detected the offending line when I don't have any debug tools available.
Dave
Many thanks Dave,
This is the only piece of code that breaks the site here http://dev.greenovalgarage.co.uk/gallery/ , I've tried removing the code bit by bit but no joy, if I remove the code altogether the page renders but without the gallery images.
Here is the gallery code, although the main image isn't being rendered, which could be part of the problem:
@gallery.Name
@noPhotos photos
Hi Nick,
I rewrote your marcro a little bit to use strongly typed syntax.
Can you check if this works for you :
Dave
Thanks Dave,
Just tried it, seems to have a missing { bracket.
Hi Nick,
Were you able to fix it ?
If not try this one
Dave
Thanks for your time on this Dave, hope I am not ruining your day. Used the code above but get a different error message now:
Ah Nick,
My mistake. Should be Model.Content.Children
And no, you are not ruining my day
Dave
Thank's Dave that did the trick, http://dev.greenovalgarage.co.uk/gallery Although the second page still errors but with something different now:
Is that the same view or another one ?
Dave
It's a different view, but the original script was in the initial post above. But it does inherit from the previous one, if that makes sense.
Hi Nick,
Can you post the code of this script ? Let's see if I can have a go at it.
Dave
Hi Dave, Thanks for your patience on this. So the first bit of code yesterday essential chooses a media folder with images in and displays the first image, and this works great now thanks to you, http://dev.greenovalgarage.co.uk/gallery/ and click on the gallery images.
The second piece of good basically displays the remaining images within that folder on a separate page this is the code:
Hi Nick,
I think this should do the trick :
Dave
Brilliant Dave, works a treat, thanks very much for your time and effort on this.
No problem... we were all new here once. And it's nice to get help.
is working on a reply...