Asp.net web api BreezeControllerAttribute异常:无法加载文件或程序集“System.Net.Http”
当我调用API时,会显示一个错误: 无法加载文件或程序集“System.Net.Http,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。系统找不到指定的文件 密码 我有一个用于API的基本控制器Asp.net web api BreezeControllerAttribute异常:无法加载文件或程序集“System.Net.Http”,asp.net-web-api,odata,breeze,Asp.net Web Api,Odata,Breeze,当我调用API时,会显示一个错误: 无法加载文件或程序集“System.Net.Http,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。系统找不到指定的文件 密码 我有一个用于API的基本控制器 [BreezeNHController] public class baseApiController<T> : ApiController where T : class, IEnti
[BreezeNHController]
public class baseApiController<T> : ApiController
where T : class, IEntity
{
public IRepository<T> Repositorio { get; private set; }
[HttpGet, BreezeNHQueryable(AllowedQueryOptions = AllowedQueryOptions.All, PageSize = 20)]
public IQueryable<T> Get()
{
return Repositorio.All();
}
// ..
}
尝试
在package Manager控制台中,运行命令Add BindingRedirect
Find strange没有指向4.0。这可能是问题所在吗?如果是,为什么添加BindingRedirect不起作用?这肯定是一个绑定重定向问题。我建议您将新的ASP.NET MVC 4项目中的全部内容复制到web.config文件中。我偶尔会遇到这种情况,刷新混乱的绑定可以解决这个问题
[BreezeController, Authorize]
public class usuariosController : baseApiController<User>
{
public usuariosController(IUserRepository repositorio)
: base(repositorio)
{ }
}
{
"Message": "An error has occurred.",
"ExceptionMessage": "The type initializer for 'Breeze.WebApi.BreezeControllerAttribute' threw an exception.",
"ExceptionType": "System.TypeInitializationException",
"StackTrace": " at Breeze.WebApi.BreezeControllerAttribute.Initialize(HttpControllerSettings settings, HttpControllerDescriptor descriptor)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor..ctor(HttpConfiguration configuration, String controllerName, Type controllerType)\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache()\r\n at System.Lazy`1.CreateValue()\r\n at System.Lazy`1.LazyInitValue()\r\n at System.Lazy`1.get_Value()\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.SelectController(HttpRequestMessage request)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Could not load file or assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.",
"ExceptionType": "System.IO.FileNotFoundException",
"StackTrace": " at Breeze.WebApi.JsonFormatter.Create()\r\n at Breeze.WebApi.BreezeControllerAttribute..cctor()"
}
}
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>