I just updated to the latest ASP.NET MVC and I am getting:
Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.MissingMethodException: Method not
found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.
Source Error:
Line 12: public static void RegisterRoutes(RouteCollection routes)
Line 13: {
Line 14: routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Line 15:
Line 16: //routes.MapRoute(
Source File: C:\ProjectX\App_Start\RouteConfig.cs Line: 14
Stack Trace:
[MissingMethodException: Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.]
System.Web.Mvc.RouteCollectionExtensions.CreateRouteValueDictionaryUncached(Object values) +0
System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url,
Object constraints) +94
System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url) +7
COP.RouteConfig.RegisterRoutes(RouteCollection routes) in C:\ProjectX\App_Start\RouteConfig.cs:14
COP.MvcApplication.Application_Start() in C:\ProjectX\Global.asax.cs:27
[HttpException (0x80004005): Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context,
HttpApplication app) +9935033
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext
context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers,
IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,
HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9913572
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,
HttpContext context) +254
I have followed this guide: http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2
I even 2nd passed the DLL list in the document as a check list to make sure I didn't miss anything. However, I am apparently missing something.
Try revert you Web.config and packages.config to previous workable version and downgrade the NuGet packs...
This is likely because your MVC has been upgraded while some relative DLL are still the old and incompatible versions...
I met a similar problem and I solved it by modifying Web.config under project folder as below:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Related
Getting a runtime exception when using MapHttpRoute extension method
Library: Microsoft.AspNet.WebApi (5.2.4), System.Web.Http (5.2.4)
Exception:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'System.Web.Http.Routing.IHttpRoute System.Web.Http.HttpRouteCollectionExtensions.MapHttpRoute(System.Web.Http.HttpRouteCollection, System.String, System.String, System.Object, System.Object, System.Net.Http.HttpMessageHandler)'.
Web.config dependent assembly mapping is also present
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
</dependentAssembly>
I have tried re-installing the Microsoft.AspNet.WebApi library but to no avail.
I have an ASP.NET 4.5.2 application that loads the Microsoft.Azure.ActiveDirectory.GraphClient library. When it tries to connect, the following error occurs:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
File Name: "System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"
bei System.Data.Services.Client.UriResolver.ConvertToAbsoluteUri(Uri baseUri)
bei System.Data.Services.Client.UriResolver.ConvertToAbsoluteAndValidateBaseUri(Uri& baseUri, String parameterName)
bei System.Data.Services.Client.DataServiceContext..ctor(Uri serviceRoot, DataServiceProtocolVersion maxProtocolVersion, ClientEdmModel model)
bei Microsoft.Azure.ActiveDirectory.GraphClient.Extensions.DataServiceContextWrapper..ctor(Uri serviceRoot, DataServiceProtocolVersion maxProtocolVersion, Func`1 accessTokenGetter, IEnumerable`1 customTypeMappings)
bei Microsoft.Azure.ActiveDirectory.GraphClient.ActiveDirectoryClient..ctor(Uri serviceRoot, Func`1 accessTokenGetter,...
I have added a binding redirect to my web.config already:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net" publicKeyToken="7cec85d7bea7798e" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.5.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
But the problem persists. What is wrong here?
I got some issues when trying to install the setup.exe. In the log it says 'the referenced assembly couldn't be found on the computer(HRESULT: 0x800736B3).
Stack:
bei System.Deployment.Internal.Isolation.IStore.GetAssemblyInformation(UInt32 Flags, IDefinitionIdentity DefinitionIdentity, Guid& riid)
bei System.Deployment.Internal.Isolation.Store.GetAssemblyManifest(UInt32 Flags, IDefinitionIdentity DefinitionIdentity)
bei System.Deployment.Application.ComponentStore.GetSubscriptionStateInternal(DefinitionIdentity subId)
bei System.Deployment.Application.SubscriptionStore.GetSubscriptionStateInternal(SubscriptionState subState)
bei System.Deployment.Application.SubscriptionState.Validate()
bei System.Deployment.Application.ComponentStore.CollectCrossGroupApplications(Uri codebaseUri, DefinitionIdentity deploymentIdentity, Boolean& identityGroupFound, Boolean& locationGroupFound, String& identityGroupProductName)
bei System.Deployment.Application.SubscriptionStore.CommitApplication(SubscriptionState& subState, CommitApplicationParams commitParams)
bei System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState& subState, ActivationDescription actDesc)
bei System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
bei System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
I've set everything I think. All the dlls are copied to the output dir. I've set the application to target x86.
app.config:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0"
invariant="System.Data.SqlServerCe"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845dcd8080cc91" culture="neutral"/>
<bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Is there anything wrong? Or why do I still getting this issue?
I am attempting to use Grid.MVC in my code. The example seems simple enough but when I try to use it I keep getting an ArrayTypeMismatchException.
This is my code. Any ideas on how i can solve it?
//This is the my cshtml code.
#Html.Grid(Model).Columns(columns =>
{
columns.Add(c => c.Name).Titled("Name");
columns.Add(c => c.Operation).Titled("Operation").Filterable(true);
}).WithPaging(3).Sortable(true)
//This is my controller code.
public ActionResult ListAllAuthorization()
{
IList<AuthorizationWrapper> authorizations;
using (GenericRepositoryV2 repo = new GenericRepositoryV2())
{
authorizations = repo.GetAllAuthorization();
}
return View(authorizations);
}
If it makes a difference, my configuration:
MVC 5
.Net framework 4.5
Update 1: The stack trace:
at System.Collections.Generic.List`1.set_Item(Int32 index, T value)
at System.Collections.ObjectModel.Collection`1.SetItem(Int32 index, T item)
at System.Web.Routing.RouteCollection.SetItem(Int32 index, RouteBase item)
at System.Collections.ObjectModel.Collection`1.set_Item(Int32 index, T value)
at System.Web.Mvc.ControllerContext.get_RequestContext()
at GridMvc.Html.GridHtmlOptions`1.RenderPartialViewToString(String viewName, Object model, ViewContext viewContext)
at GridMvc.Html.GridHtmlOptions`1.ToHtmlString()
at System.Web.HttpUtility.HtmlEncode(Object value)
at System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, Object content)
at System.Web.WebPages.WebPageBase.Write(Object value)
at ASP._Page_Views_Admin_ListAllAuthorization_cshtml.Execute() in e:\Oman-Erp\OmanERP\Views\Admin\ListAllAuthorization.cshtml:line 28
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.StartPage.RunPage()
at System.Web.WebPages.StartPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
This is a long shot but I think you should try it.
According to the documentation page of ArrayTypeMismatchException
ArrayTypeMismatchException is thrown when the system cannot convert the element to the type declared for the array. For example, an element of type String cannot be stored in an Int32 array because conversion between these types is not supported.
Looking at the stack trace you provided, I'm inclined to believe that there is a problem with the model you are passing to the view/grid. As can bee seen from the action method, you're passing a list of AuthorizationWrapper objects and the type checking would prevent you from storing something else in that list so the problem is somewhere in between.
Start by checking the Model property of the view in debug; if everything is ok, just download the source code, build it locally and see (in debug mode) where the exception pops up. That's the great part of Open Source :)
You need to include this in web.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
nLog does not work when I upgrade my project to the latest mongoDB Driver:
---> System.TypeInitializationException: The type initializer for 'NLog.Mongo.MongoTarget' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'MongoDB.Driver, Version=1.9.2.235, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at NLog.Mongo.MongoTarget..cctor()
--- End of inner exception stack trace ---
at NLog.Mongo.MongoTarget..ctor()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at NLog.Internal.FactoryHelper.CreateInstance(Type t)
It logs nothing. I am using a mongoDB target for nLog. I already posted an issue (https://github.com/loresoft/NLog.Mongo/issues/7). But maybe there is a way to solve it on my own.
Any suggestions?
The target works with official mongoDB driver versions before 1.9.
You can add an Assembly binding to your web.config
<runtime>
<dependentAssembly>
<assemblyIdentity name="MongoDB.Driver" publicKeyToken="f686731cfb9cc103" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.10.0.62" newVersion="1.10.0.62" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MongoDB.Bson" publicKeyToken="f686731cfb9cc103" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.10.0.62" newVersion="1.10.0.62" />
</dependentAssembly>
</runtime>