我在管理员模式下使用 Visual Studio 2015 社区版。我安装了SideWaffle Template Pack v1.21.400。我创建了一个新的Nancy Empty Self Host Project。以下是源代码:
using System;
using Nancy.Hosting.Self;
namespace NancyEmptySelfHost
{
class Program
{
static void Main(string[] args)
{
var uri =
new Uri("http://localhost:3579");
using (var host = new NancyHost(uri))
{
host.Start();
Console.WriteLine("Your application is running on " + uri);
Console.WriteLine("Press any [Enter] to close the host.");
Console.ReadLine();
}
}
}
}
在执行时,我收到System.AccessViolationException并host.Start();
显示以下消息:
尝试读取或写入受保护的内存。这通常表明其他内存已损坏。
当我使用其他 Nancy 模板创建项目时,我得到了同样的例外。如果我创建一个控制台应用程序(不使用 Nancy 模板)并引用 Nancy dll,它工作正常。这应该如何解决?