Ste*_*tri 9 c# iis-express owin
这里有另一个类似于SignalR 2.0.2和Owin 2.0.0依赖冲突的问题.如果我将项目作为控制台应用程序运行我很好.否则,作为类库,如果我从命令提示符运行它,我从IIS Express收到此错误说:
Could not load file or assembly 'Microsoft.Owin, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)
但它不可能,因为我已经安装了3.0.0.0并且在配置文件中我有:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<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>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这里是应用程序的其余部分:
namespace katanaIntro
{
using AppFunc = Func<IDictionary<string, object>, Task>;
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Use(async (environment, next) =>
{
Console.WriteLine("Requestion : " + environment.Request.Path);
await next();
Console.WriteLine("Response : " + environment.Response.StatusCode);
});
ConfigureWebApi(app);
app.UseHelloWorld();
}
private void ConfigureWebApi(IAppBuilder app)
{
var config = new HttpConfiguration();
config.Routes.MapHttpRoute(
"DefaultApi",
"api/{controller}/{id}",
new { id = RouteParameter.Optional });
app.UseWebApi(config); // <-- It works without this!!!
}
}
public static class AppBuilderExtensions
{
public static void UseHelloWorld(this IAppBuilder app)
{
app.Use<HelloWorldComponent>();
}
}
public class HelloWorldComponent
{
AppFunc _next;
public HelloWorldComponent(AppFunc next)
{
_next = next;
}
public Task Invoke(IDictionary<string, object> environment)
{
var response = environment["owin.ResponseBody"] as Stream;
using (var writer = new StreamWriter(response))
{
return writer.WriteAsync("Hello!!!");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这里是来自命令提示符的指令:
"c:\Program Files\IIS Express\iisexpress.exe" /path:"C:\Users\smagistri\Projects\Lab 4.5\katanaIntro\katanaIntro"
Run Code Online (Sandbox Code Playgroud)
忘记提到它只有在我删除ConfigureWebApi(app)时才有效;
有任何想法吗?
Ste*_*tri 44
我只需要将App.config重命名为Web.config或制作它的副本并将其命名为Web.config并且它可以工作.
| 归档时间: |
|
| 查看次数: |
6774 次 |
| 最近记录: |