This is a migrated thread and some comments may be shown as answers.

[Solved] Problem with .Action()

3 Answers 154 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Strasser
Top achievements
Rank 1
Michael Strasser asked on 08 Jan 2010, 08:56 PM
Hello,

Using the Html.Telerik().Menu().Items() and add a new item using the .Action()

Sample (param values are all Guids):

Html.Telerik().Menu()
                            .Name(string.Format("EntityMenux{0}", entity.Id.ToString()))
                            .Items(menu =>
                            {
                                menu.Add()
                                    .Text("Options")
                                    .Items(item =>
                                    {
                                            item.Add()
                                            .HtmlAttributes(new { title = "Click to edit this contact." })
                                            .Text("Edit")
                                            .ImageUrl("~/content/styles/common/menuicons/edit.png")
                                            .Action("EditContactMethod", "Staff", new { id = entity.Id, ownerId = entity.OwnerId, organizationId = entity.Organization.Id });
                                    }
                                    );
                            }
                            )
                            .Orientation(MenuOrientation.Vertical)
                            .HighlightPath(true)
                            .OpenOnClick(false)
                            .Render();



I receive the following exception:

System.IO.FileLoadException was unhandled by user code
  Message="Could not load file or assembly 'Telerik.Web.Mvc, Version=2009.2.812.0, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
  Source="mscorlib"
  FileName="Telerik.Web.Mvc, Version=2009.2.812.0, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
  FusionLog="=== Pre-bind state information ===\r\nLOG: User = ODIN\\strasser\r\nLOG: DisplayName = Telerik.Web.Mvc, Version=2009.2.812.0, Culture=neutral, PublicKeyToken=121fae78165ba3d4\n (Fully-specified)\r\nLOG: Appbase = file:///C:/Apps/VisualStudio/Felix/Development/FelixGO/FelixGO.Web/\r\nLOG: Initial PrivatePath = C:\\Apps\\VisualStudio\\Felix\\Development\\FelixGO\\FelixGO.Web\\bin\r\nCalling assembly : Mvc.UI.jQuery, Version=2009.2.812.0, Culture=neutral, PublicKeyToken=null.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: C:\\Apps\\VisualStudio\\Felix\\Development\\FelixGO\\FelixGO.Web\\web.config\r\nLOG: Using machine configuration file from c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\config\\machine.config.\r\nLOG: Post-policy reference: Telerik.Web.Mvc, Version=2009.2.812.0, Culture=neutral, PublicKeyToken=121fae78165ba3d4\r\nLOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/bac190d9/b56ed25d/Telerik.Web.Mvc.DLL.\r\nLOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/bac190d9/b56ed25d/Telerik.Web.Mvc/Telerik.Web.Mvc.DLL.\r\nLOG: Attempting download of new URL file:///C:/Apps/VisualStudio/Felix/Development/FelixGO/FelixGO.Web/bin/Telerik.Web.Mvc.DLL.\r\nWRN: Comparing the assembly name resulted in the mismatch: Minor Version\r\nERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.\r\n"
  StackTrace:
       at System.Reflection.Assembly._GetExportedTypes()
       at System.Reflection.Assembly.GetExportedTypes()
       at Telerik.Web.Mvc.Infrastructure.Implementation.ControllerTypeCache.<>c__DisplayClassb.<GetAllControllerTypes>b__9(Assembly assembly)
       at Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each[T](IEnumerable`1 instance, Action`1 action)
       at Telerik.Web.Mvc.Infrastructure.Implementation.ControllerTypeCache.GetAllControllerTypes()
       at Telerik.Web.Mvc.Infrastructure.Implementation.ControllerTypeCache.EnsureInitialized()
       at Telerik.Web.Mvc.Infrastructure.Implementation.ControllerTypeCache.GetControllerTypeWithinNamespaces(String controllerName, IEnumerable`1 namespaces)
       at Telerik.Web.Mvc.Infrastructure.Implementation.ControllerTypeCache.GetControllerType(RequestContext requestContext, String controllerName)
       at Telerik.Web.Mvc.Infrastructure.Implementation.AuthorizeAttributeCache.GetAuthorizeAttributes(RequestContext requestContext, String controllerName, String actionName)
       at Telerik.Web.Mvc.Infrastructure.Implementation.ControllerAuthorization.IsAccessibleToUser(RequestContext requestContext, String controllerName, String actionName)
       at Telerik.Web.Mvc.Infrastructure.Implementation.NavigationItemAuthorization.IsAccessibleToUser(RequestContext requestContext, INavigatable navigationItem)
       at Telerik.Web.Mvc.UI.NavigatableExtensions.<>c__DisplayClass1`1.<IsAccessible>b__0(T item)
       at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
       at Telerik.Web.Mvc.UI.NavigatableExtensions.IsAccessible[T](IEnumerable`1 items, INavigationItemAuthorization authorization, ViewContext viewContext)
       at Telerik.Web.Mvc.UI.Menu.WriteContent(MenuItem item, IMenuRenderer renderer)
       at Telerik.Web.Mvc.UI.Menu.WriteItem(MenuItem item, IMenuRenderer renderer)
       at Telerik.Web.Mvc.UI.Menu.<>c__DisplayClass7.<WriteHtml>b__6(MenuItem item)
       at Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each[T](IEnumerable`1 instance, Action`1 action)
       at Telerik.Web.Mvc.UI.Menu.WriteHtml(HtmlTextWriter writer)
       at Telerik.Web.Mvc.UI.ViewComponentBase.Render()
       at Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render()
       at ASP.views_staff_summarycontactmethods_aspx.<>c__DisplayClasse.<__Renderform1>b__3(ContactMethod entity) in c:\Apps\VisualStudio\Felix\Development\FelixGO\FelixGO.Web\Views\Staff\SummaryContactMethods.aspx:line 86
       at Telerik.Web.Mvc.UI.GridRenderer`1.RowCellContent(GridCellRenderingContext`1 renderingContext)
       at Telerik.Web.Mvc.UI.Grid`1.WriteCell(IGridRenderer`1 renderer, GridColumn`1 column, T row, Int32 rowIndex)
       at Telerik.Web.Mvc.UI.Grid`1.<>c__DisplayClass1e.<WriteRow>b__1d(GridColumn`1 column)
       at Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each[T](IEnumerable`1 instance, Action`1 action)
       at Telerik.Web.Mvc.UI.Grid`1.WriteRow(IGridRenderer`1 renderer, T row, Int32 index)
       at Telerik.Web.Mvc.UI.Grid`1.<>c__DisplayClass1b.<WriteRows>b__18(T row)
       at Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each[T](IEnumerable`1 instance, Action`1 action)
       at Telerik.Web.Mvc.UI.Grid`1.WriteRows(IGridRenderer`1 renderer)
       at Telerik.Web.Mvc.UI.Grid`1.WriteTable(IGridRenderer`1 renderer)
       at Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer)
       at Telerik.Web.Mvc.UI.ViewComponentBase.Render()
       at Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render()
       at ASP.views_staff_summarycontactmethods_aspx.__Renderform1(HtmlTextWriter __w, Control parameterContainer) in c:\Apps\VisualStudio\Felix\Development\FelixGO\FelixGO.Web\Views\Staff\SummaryContactMethods.aspx:line 78
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
       at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Control.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Apps\VisualStudio\Felix\Development\FelixGO\FelixGO.Web\Views\Shared\Site.Master:line 52
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Control.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Page.Render(HtmlTextWriter writer)
       at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:


Note:  As a work around I'm also attempting to use .Url()

Sample:
Url(Url.Action("EditContactMethod", "Staff", new { id = entity.Id, ownerId = entity.OwnerId, organizationId = entity.Organization.Id }))



But the generated code seems to be dropping the last param when I use more that 2 parameters. 

I'm using this successfully where there are 1 or 2 params, but when I use 3 params, the 3rd is missing within the link.

Note:  there are no Null values in the params.

Thanks!
Mike

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 11 Jan 2010, 10:31 AM
Hi Michael,

Unfortunately I could not reproduce the depicted issue. I have created a test project in my attempt to replicate this issue. I have attached it to this thread.

One possible cause of the thrown exception is different Telerik.Web.Mvc.dll version declared into web.config to the referenced one.

All the best,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Michael Strasser
Top achievements
Rank 1
answered on 11 Jan 2010, 06:55 PM
Okay.

How do I clean up this reference so it uses the latest (2009.3.1223) DLL version (instead of the 2009.2.812 version I was using previously)?

The only reference I have is to that (2009.3.1223) DLL in my project.

Many Thanks!
Mike
0
Georgi Krustev
Telerik team
answered on 13 Jan 2010, 08:52 AM
Hello Michael,

Please verify that the correct assembly is referenced in the project (expand Reference section and check what is the version of the current Telerik.Web.Mvc.dll). If it is not correct, reference the right one.

Other check you can perform is to verify that you did not add a reference to Telerik.Web.Mvc.dll, where you specify which is the version of the assembly.

You can also try to clean the project.

Could you please share did you have any problems running the attached test project in my last post?

Greetings,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Menu
Asked by
Michael Strasser
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Michael Strasser
Top achievements
Rank 1
Share this question
or