我尝试安装由Owinhost.exe托管的web api应用程序
启动时收到此错误消息:
Error: System.ArgumentException
No conversion available between System.Func2[System.Collections.Generic.IDictionary2[System.String,System.Object],System.Threading.Tasks.Task] and Microsoft.Owin.OwinMiddleware.
Parameter name: signature
我的图书馆项目宣布:
public class Startup
{
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
"Default",
"{controller}/{id}",
new { id = RouteParameter.Optional });
app.UseWebApi(config);
}
}
我的包是这个:
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.1.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.1.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.1.2" targetFramework="net45" />
<package id="Microsoft.Owin" version="2.1.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
</packages>
有人有想法吗?
答案 0 :(得分:0)
错误的原因是OwinHost在项目根目录的web.config文件中查找绑定重定向。要解决此问题,请将web.config文件放在当前目录(bin文件夹上一级),然后将以下重定向放入其中:
<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
以下是Web API CodePlex网站上的问题链接:https://aspnetwebstack.codeplex.com/workitem/2116
干杯, 贝