Item 10 of 18 Previous | Next

2
Vote

Issue with templateArguments

description

The Razor.cs class in the project DDRMenu_NET4.0 throw an exeption when she try to affecte the parameter from templateArguments to the model.

-- Patch replace in the Execute function :
foreach (var arg in templateArguments)
{
model[arg.Key] = arg.Value;
}

with :
var dicModel = model as IDictionary<string, object>;
foreach (var arg in templateArguments)
{
dicModel[arg.Key] = arg.Value;
}

No files are attached

comments

dukesb11 wrote Jan 25 at 5:46 PM

I'm seeing this, too. Supplying a template argument to a razor template (whether via menudef.xml or the control in the skin) causes an exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot apply indexing with [] to an expression of type 'System.Dynamic.ExpandoObject' at CallSite.Target(Closure , CallSite , Object , String , String ) at DotNetNuke.Web.DDRMenu.Razor.Execute(String virtualPath, HtmlTextWriter htmlWriter, Object source, String controlID, String clientOptions, String dnnPath, String manifestPath, String portalPath, String skinPath, Dictionary`2 templateArguments) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at DotNetNuke.Web.DDRMenu.TemplateEngine.RazorTemplateProcessor.Render(Object source, HtmlTextWriter htmlWriter, TemplateDefinition liveDefinition)