here another question similar to SignalR 2.0.2 and Owin 2.0.0 dependency conflict. If I run the project as Console Application I'm fine. Otherwise, as class library if I run it from command prompt I got this error from IIS Express saying:
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)
But it cannot be, as I have installed 3.0.0.0 and in the config file I have:
<?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>
Here the rest of the application:
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!!!");
}
}
}
}
Here the instruction from command prompt:
"c:\Program Files\IIS Express\iisexpress.exe" /path:"C:\Users\smagistri\Projects\Lab 4.5\katanaIntro\katanaIntro"
Forgot to mention that it works only if I remove the ConfigureWebApi(app);
Any ideas?
Go to project Refrences & find out Microsoft.Owin. Right click on it & check the version on properties.
Project Assembly version & below line of webconfig newVersion should be same.
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
I only need to rename the App.config to Web.config or make a copy of it and name it Web.config and it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With