Ullas Prabhu
Ullas Prabhu

Reputation: 239

Error at app.useMvc

I am running ASP.NET Vnext web app on VS 2015 CTP5.

I am getting a TypeLoadException:

An exception of type 'System.TypeLoadException' occurred in mscorlib.dll but was not handled in user code

Additional information:

Could not load type 'System.Web.Http.RouteAttribute' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

at this line -

app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller}/{action}/{id?}",
                defaults: new { controller = "Home", action = "Index" });
        });

These are the dependencies in my project.json:

"dependencies": {
    "EntityFramework.SqlServer": "7.0.0-beta2",
    "EntityFramework.Commands": "7.0.0-beta2",
    "Microsoft.AspNet.Hosting": "1.0.0-beta2",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta2",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta2",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta2",
    "Microsoft.AspNet.Security.Cookies": "1.0.0-beta2",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta2",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta2",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta2",
    "Microsoft.AspNet.Mvc": "6.0.0-beta2",
    "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta2",
    "Microsoft.AspNet.RequestContainer": "1.0.0-beta2",
    "Microsoft.AspNet.WebUtilities": "1.0.0-beta2",
    "Microsoft.AspNet.Web.Optimization": "1.0.0-beta2",
    "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta2",
    "Microsoft.Framework.DependencyInjection": "1.0.0-beta2",
    "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta2",
    "Microsoft.Framework.Logging": "1.0.0-beta2",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta2",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta1",
    "AutoMapper": "3.2.1",
    "Microsoft.ApplicationInsights.Telemetry.Services": "0.7.1.0",
    "Microsoft.Web.Infrastructure": "1.0.0.0",
    "Microsoft.Web.DistributedCache": "",
    "System.IdentityModel.Tokens.ValidatingIssuerNameRegistry": "4.5.1",
    "System.Spatial": "5.6.1",
    "Microsoft.WindowsAzure.ConfigurationManager": "2.0.3",
    "Microsoft.WindowsAzure.Caching": "2.5.0.0",
    "Microsoft.WindowsFabric.Common": "",
    "Microsoft.WindowsFabric.Data.Common": "",
    "Unity.WebAPI": "5.1",
    "Microsoft.Data.Edm": "5.6.2",
    "Microsoft.Data.OData": "5.6.2",
    "Microsoft.Data.Services.Client": "5.6.2",
    "WindowsAzure.Storage": "4.3.0.0",
    "Newtonsoft.Json": "6.0.8.0",
    "Unity": "3.5.1404.0"
},

Upvotes: 2

Views: 1907

Answers (1)

Yishai Galatzer
Yishai Galatzer

Reputation: 8862

Looks like you are referencing system.web this is not supported and you shouldn't do that. Look at your project.json and remove references to system.web or any packages depending on system.web.

Edit: Specifically Microsoft.Web.Infrastructure references System.Web (and is not supported).

Start by building you app component by component, instead of trying to just copy the references over to project.json.

You can expand the references node in visual studio to see the dependencies each root level dependency brings with it.

Note - No oData support is available for vNext, no Unity support yet either and it will not be Unity.WebAPI when it happens

Upvotes: 1

Related Questions