我正在使用VS 2015 Community并尝试创建一个WebServer Console,使用这些“简单”的教程:
OWIN和Katana part 1: the basics
ASP.NET Fundamentals
这两个教程看起来很容易,但是当我尝试编译它们时,我几乎在同一个地方卡住了。这两个教程都引用了DNX 4.5.1(Microsoft.Owin.Host.HttpListener(3.0.1)和Microsoft.Owin.Hosting(3.0.1))和DNX Core 5.0。以下是第一个链接的代码(与第二个链接几乎相同(包括错误),因此我不会包含该代码):
我在“owinContext =>”处开始看到红色的波浪线,一直延续到该方法的结尾。 当我尝试编译时,这里是我收到的错误信息:
Owin 不支持 DNX Core 5.0,但支持 DNX 4.5.1。我原以为可以将其移动或复制到 DNX 4.5.1,但似乎 DNX Core 5.0 是默认的选择。
我找到了类似问题的解决方法,但是并不理解所有的解释。例如,我看到一篇帖子说要更改目标,但我甚至找不到他们所描述的“修复”内容在哪里或是什么。所以,似乎我需要一个早期版本的 DNX Core 5.0?如果是这样,我该如何引用早期版本呢?非常感谢!
OWIN和Katana part 1: the basics
ASP.NET Fundamentals
这两个教程看起来很容易,但是当我尝试编译它们时,我几乎在同一个地方卡住了。这两个教程都引用了DNX 4.5.1(Microsoft.Owin.Host.HttpListener(3.0.1)和Microsoft.Owin.Hosting(3.0.1))和DNX Core 5.0。以下是第一个链接的代码(与第二个链接几乎相同(包括错误),因此我不会包含该代码):
using Microsoft.Owin.Hosting;
using Owin;
using System;
namespace KatanaBasics
{
public class Program
{
public static void Main(string[] args)
{
string uri = "http://localhost:7990";
using (WebApp.Start<startup>(uri))
{
Console.WriteLine("Web server on {0} starting.", uri);
Console.ReadKey();
Console.WriteLine("Web server on {0} stopping.", uri);
}
}
}
public class startup
{
public void Configuration(IAppBuilder appBuilder)
{
appBuilder.Run(owinContext =>
{
owinContext.Response.WriteAsync("Hello from OWIN web server");
});
}
}
}
我在“owinContext =>”处开始看到红色的波浪线,一直延续到该方法的结尾。 当我尝试编译时,这里是我收到的错误信息:
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Owin' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) KatanaBasics.DNX Core 5.0
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'Owin' could not be found (are you missing a using directive or an assembly reference?) KatanaBasics.DNX Core 5.0
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'IAppBuilder' could not be found (are you missing a using directive or an assembly reference?) KatanaBasics.DNX Core 5.0
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'WebApp' does not exist in the current context KatanaBasics.DNX Core 5.0
Severity Code Description Project File Line Suppression State
Error CS1643 Not all code paths return a value in lambda expression of type 'Func<IOwinContext, Task>' KatanaBasics.DNX 4.5.1
Owin 不支持 DNX Core 5.0,但支持 DNX 4.5.1。我原以为可以将其移动或复制到 DNX 4.5.1,但似乎 DNX Core 5.0 是默认的选择。
我找到了类似问题的解决方法,但是并不理解所有的解释。例如,我看到一篇帖子说要更改目标,但我甚至找不到他们所描述的“修复”内容在哪里或是什么。所以,似乎我需要一个早期版本的 DNX Core 5.0?如果是这样,我该如何引用早期版本呢?非常感谢!
true
。 - MethodMan