An expression tree may not contain a dynamic operation

Nov 8, 2010 at 9:53 PM

Hi,

Great work by the way, looking to get involved :)

Looking at Orchard as a software developer I thought I would write a module, so I have followed the "Writing a content part" tutorial that was recently updated for 0.8.  I added the new Maps feature to the Page Content Type, however when I go to edit the page I get a compilation error "CS1963: An expression tree may not contain a dynamic operation".  It points to line 7 in ..\Maps\Views\EditorTemplates\Parts\Map.cshtm the line is

@Html.LabelFor(model => model.Latitude)

I can't seem to figure this one out, any ideas? I thought I would download the module from the gallery to check I had followed everything correctly, however that version seems to use a user control instead of a cshtml page.

Thanks,

Jeff

Hi,

Great work by the way, looking to get involved :)

Looking at Orchard as a software developer I thought I would write a module, so I have followed the "Writing a content part" tutorial that was recently updated for 0.8.  I added the new Maps feature to the Page Content Type, however when I go to edit the page I get a compilation error "CS1963: An expression tree may not contain a dynamic operation".  It points to line 7 in ..\Maps\Views\EditorTemplates\Parts\Map.cshtm the line is

@Html.LabelFor(model => model.Latitude)

I can't seem to figure this one out, any ideas? I thought I would download the module from the gallery to check I had followed everything correctly, however that version seems to use a user control instead of a cshtml page.

Thanks,

Jeff
Coordinator
Nov 8, 2010 at 10:10 PM

Yes, that's a limitation of C#4 that can't use Lambdas with dynamic objects. You need to choose between using a strongly typed view model like lots of editor views are still doing, or use shapes. If you use shapes, you'll need to use the non-strongly-typed overloads of the Html helpers, or shape templates, or shape methods for rendering.

Eventually, we want to have standard shapes for textboxes and other form elements, but we're not quite there yet.

Nov 9, 2010 at 5:02 PM

I encountered this issue as well.

To fix it, change the first line: "@Model Maps.Models.MapPart".
It must be "@model ..." (lower case "m").

Coordinator
Nov 9, 2010 at 5:05 PM

Ah, yes, thanks, I had somehow missed the crucial information that this was in the tutorial. I'll fix it.

Nov 9, 2010 at 9:05 PM
Arrrhhh yes thank you, works great now :)

Jeff

On 9 Nov 2010, at 17:05, "bertrandleroy" <notifications@codeplex.com> wrote:

From: bertrandleroy

Ah, yes, thanks, I had somehow missed the crucial information that this was in the tutorial. I'll fix it.

Read the full discussion online.

To add a post to this discussion, reply to this email (orchard@discussions.codeplex.com)

To start a new discussion for this project, email orchard@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com