Ich versuche, Nancy in .NET 4.6.1 (Visual Studio 2015 Update 2) zu verwenden. Wenn ich eine Konsolen-App, die das .NET 4.6.1 Framework basierend auf dem Code & Referenzen unten verweist, sehe ich eine Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
zwischen meinem eigenen Beispiel Stub
und Nancy.Response
, während nie eine JSON-Ausgabe erhalten. Gibt es etwas, was mir auf dem Super-Duper-Happy-Path fehlt? Ich verstehe, dass ich keine Ansicht angegeben habe, aber ich beabsichtige, diese Ressource nur mit einem Accept-Header von: Accept: application/json
aufzurufen. Ich führe Visual Studio als "Administrator" aus und das Betriebssystem ist Windows 7 x64 (mit den meisten Updates).Nancy Self-Hosted RunTimeBinderException
Program.cs:
using System;
namespace SelfHostedTest
{
class Program
{
static void Main(string[] args)
{
var host = new SelfHoster();
host.Create("http://localhost:8002");
Console.WriteLine("Started");
Console.ReadLine();
host.Destroy();
}
}
}
RootModule.cs:
using Nancy;
namespace SelfHostedTest
{
public class Stub
{
public int Number { get; set; }
public string Message { get; set; }
}
public class RootModule : NancyModule
{
public RootModule()
{
Get["/"] = _ => new Stub() {Message = "Hello", Number = 1};
}
}
}
SelfHoster.cs:
using System;
using Nancy;
using Nancy.Hosting.Self;
namespace SelfHostedTest
{
public class SelfHoster
{
private NancyHost _host;
public void Create(string url)
{
_host = new NancyHost(new Uri(url), new DefaultNancyBootstrapper());
_host.Start();
}
public void Destroy()
{
_host?.Stop();
}
}
}
Referenzen:
Microsoft.CSharp
Nancy (1.4.3)
Nancy.Hosting.Self (1.4.1)
Nancy.Serialization.JsonNet (1.4.1)
Newtonsoft.Json (8.0.3)
System
System.Core
System.Data
System.Data.DataSetExtensions
System.Net.Http
System.Xml
System.Xml.Linq
Mein ultimatives Ziel ist es, dies in ein selbst gehostetes OWIN-Modul mit Websockets zu bringen, aber ich habe es zurückgenommen, um mein Problem zu isolieren.