Reputation: 251
For some reason Visual Studio Gives me this error in the view:
Cannot convert lambda expression to type 'System.Linq.Expressions.Expression>' because it is not a delegate type
Also, I do not have intellisense on the lambda.
I made sure to knock my MVC version down to 5.1.0 based on this post:
Sitecore glass editable cannot convert lambda expression
Unfortunately, I didnt have the Stack Overflow points needed to comment directly on that post. Double unfortunately, the MVC version solution did not work for me. When I publish to deploy, the data comes through just fine - the editing works just fine - but I'd rather not just ignore red squiggly lines and lack of intellisense.
From a fresh Sitecore 8/Visual Studio MVC Application setup, I Ran:
Update-Package Glass.Mapper.Sc.CastleWindsor to give me v3.3.1.26
Then I ran Install-Package Glass.Mapper.Sc.Mvc-5 to give me v3.3.1.48
I set up a Model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Glass.Mapper.Sc;
using Glass.Mapper.Sc.Configuration.Attributes;
namespace myns.app.Models
{
[SitecoreType]
public class BaseContent
{
[SitecoreId]
public virtual Guid Id { get; set; }
[SitecoreField("Content Title")]
public virtual string Title { get; set; }
[SitecoreField("Summary Content")]
public virtual string Summary { get; set; }
[SitecoreField("Full Content")]
public virtual string Content { get; set; }
[SitecoreField("Content Image")]
public virtual Glass.Mapper.Sc.Fields.Image ImagePath { get; set; }
}
}
And have a sort-of working view
@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<myns.app.Models.BaseContent>
<div>
<h4>BaseContent</h4>
<hr />
@Model.Title
<p>@Editable(Model, x => x.Title)</p>
<p>@Editable(Model, x => x.Summary)</p>
<h5>content</h5>
<p>@Editable(Model, x => x.Content)</p>
<p>@RenderImage(Model, x => x.ImagePath)</p>
</div>
Thanks in advance to any input!
UPDATE: When I comment out the following three lines in the compilation>assemblies in the web.config Sitecore provides, the problem seems to go away. Not sure this is the best thing to do:
<compilation defaultLanguage="c#" debug="false" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=5.2.2.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<!--add assembly="System.Web.Http, Version=5.1.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" /-->
<!--add assembly="System.Web.Http.WebHost, Version=5.1.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" /-->
<!--add assembly="System.Net.Http.Formatting, Version=5.1.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" /-->
</assemblies>
</compilation>
Upvotes: 4
Views: 2404
Reputation: 251
Commenting out the following three lines in the assemblies node within the site's web.config fixed the problem.
<!--add assembly="System.Web.Http, Version=5.1.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" /-->
<!--add assembly="System.Web.Http.WebHost, Version=5.1.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" /-->
<!--add assembly="System.Net.Http.Formatting, Version=5.1.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" /-->
Upvotes: 3
Reputation: 6518
A quick test for me shows that there are no problems. I am using the latest Glass releases for all assemblies. Ensure that you have the correct assembly binding redirects in both the web.config and /views/web.config:
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
Upvotes: 0