After building and successfully running a self-hosted NancyFx application on windows with visual studio I went on and tried to run the application on linux with mono. I was able to build the solution (using xbuild) but when running the app I get a strange error:
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
System.TypeLoadException: Could not load type 'System.Net.HttpListener'
from assembly 'System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'.
at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Initialize (IDictionary`2 properties) <0x413ae4f0 + 0x000eb> in <filename unknown>:0
For some reason, the app tries to initialize class HttpListener
from the System
assembly, but HttpListener
lives in System.Net
assembly. I looked in the GAC folder and found that System.Net
is there as expected. I moved a copy to the bin
folder where the other dependencies of the app live but that didn't solve the problem. Any help would be appreciated!!
here is my OWIN-related code:
// Startup.cs
using Owin;
namespace MyApp
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseNancy();
}
}
}
// Program.cs
using System;
using Microsoft.Owin.Hosting;
namespace MyApp
{
public class Program
{
static void Main(string[] args)
{
var url = "http://127.0.0.1:8080/";
using (WebApp.Start<Startup>(url))
{
Console.WriteLine("Running on {0}", url);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
}
}
}
I've got same exception. =/
RépondreSupprimer