Question

I'm trying to add upshot goodness to an existing MVC project.

On the line

@(Html.UpshotContext().DataSource<DataServiceController>(x => x.GetAllProducts()))

I'm getting the exception

Could not load file or assembly 'System.Web.Http.Common, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. 
The system cannot find the file specified.

My list of installed nuget packages is

<packages>
  <package id="AspNetMvc" version="4.0.20505.0" />
  <package id="AspNetWebApi" version="4.0.20505.0" />
  <package id="AspNetWebApi.Data" version="4.0.20221.15125" />
  <package id="EntityFramework" version="4.3.1" />
  <package id="jQuery" version="1.7.2" />
  <package id="jQuery.Ajax.Unobtrusive" version="2.0.20505.0" />
  <package id="jQuery.UI.Combined" version="1.8.20" />
  <package id="jQuery.Validation" version="1.9" />
  <package id="jQuery.Validation.Unobtrusive" version="2.0.20505.0" />
  <package id="knockoutjs" version="2.1.0" />
  <package id="Microsoft.AspNet.Mvc" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.Razor" version="2.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20505.0" />
  <package id="Microsoft.AspNet.WebPages" version="2.0.20505.0" />
  <package id="Microsoft.jQuery.Unobtrusive.Ajax" version="2.0.20505.0" />
  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="2.0.20505.0" />
  <package id="Microsoft.Net.Http" version="2.0.20505.0" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
  <package id="Modernizr" version="2.5.3" />
  <package id="Newtonsoft.Json" version="4.5.7" />
  <package id="Ninject" version="3.0.1.10" />
  <package id="Ninject.MVC3" version="3.0.0.6" />
  <package id="Ninject.Web.Common" version="3.0.0.7" />
  <package id="SinglePageApplication" version="4.0.20221.15125" />
  <package id="Upshot" version="1.0.0.2" />
  <package id="WebActivator" version="1.5.1" />
</packages>

Google gives me nothing for that exception. Any ideas?

edit: Thought the complete stacktrace might be of use:

[FileNotFoundException: Could not load file or assembly 'System.Web.Http.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.Http.Data.Metadata.MetadataProviderAttribute..ctor(Type providerType) +0
   System.Web.Http.Data.EntityFramework.Metadata.DbMetadataProviderAttribute..ctor() +77
   System.RuntimeTypeHandle.CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor) +0
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +1539
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) +161
   System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit) +58
   System.Web.Http.Data.DataControllerDescription.CreateMetadataProvider(Type dataControllerType) +455
   System.Web.Http.Data.DataControllerDescription.CreateDescription(HttpControllerDescriptor controllerDescriptor) +134
   System.Web.Http.Data.<>c__DisplayClass1.<GetDescription>b__0(Type type) +42
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +62
   System.Web.Http.Data.DataControllerDescription.GetDescription(HttpControllerDescriptor controllerDescriptor) +158
   System.Web.Http.Data.Helpers.MetadataExtensions.Metadata(HtmlHelper htmlHelper) +215

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +92
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +110
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   System.Web.Http.Data.Helpers.UpshotConfigBuilder.GetMetadata(Type dataControllerType) +233
   System.Web.Http.Data.Helpers.UpshotConfigBuilder.ToHtmlString() +360
   System.Web.HttpUtility.HtmlEncode(Object value) +38
   System.Web.WebPages.WebPageBase.Write(Object value) +68
   ASP._Page_Views_Search_Index_cshtml.Execute() in c:\code\Website\Views\Search\Index.cshtml:11
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +97
   System.Web.WebPages.StartPage.RunPage() +17
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +62
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +260
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +295
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +89
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__4(IAsyncResult asyncResult) +25
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +48
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9615056
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Was it helpful?

Solution

As per the discussion on this thread: Current SPA (beta) is not compatible with MVC 4 RC

The ASP.NET team are recommending people stick with MVC4 beta + SPA Nuget package for the time being. An alternative suggested is to grab the code for the conflicted libraries and build them yourself but that's just asking for headaches and rework as the team moves forward.

OTHER TIPS

Try installing it from NuGet:

PM> Install-Package System.Web.Http.Common
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top