Tilting Code
Tilting Code

Reputation: 137

CS0234 The type or namespace name 'Owin' does not exist in the namespace 'Microsoft'

I'm using VS 2015 Community and attempting to create a WebServer Console using these "simple" tutorials:

OWIN and Katana part 1: the basics

ASP.NET Fundamentals

Both tutorials seem easy enough, however, I pretty much get stuck at the same spot when I try to compile them. Both tutorials reference DNX 4.5.1 (Microsoft.Owin.Host.HttpListener (3.0.1) and Microsoft.Owin.Hosting (3.0.1)) & DNX Core 5.0. Here is the code from the first link (which is almost identical (including errors) to the second link so I will not include that code):

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");
        });
      }
  }
}

I get the red squiggly lines starting at owinContext => and it continues till the end of the method. And here are the errors I get when I try to compile:

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 is not in DNX Core 5.0 but it is in DNX 4.5.1. I thought maybe I could move or copy to DNX 4.5.1 but it seems DNX Core 5.0 is where it wants to default.

I have found resolutions to similar problems but I do not understand all the explanations. For instance I read one post that said to change targets, however, I couldn't even find anything like what or where they described to "fix" it. So, it seems maybe I need an earlier of DNX Core 5.0? If so, how do I reference an earlier version? Thanks much!

Upvotes: 3

Views: 15356

Answers (2)

f.capet
f.capet

Reputation: 39

in vs, go to Tools-> Nuget Package Manager -> Package Manager Console and type: Update-Package

Upvotes: 2

Jason Roos
Jason Roos

Reputation: 81

I am having the same issue. For grins, I hit ctrl-F5 and when it asked me if I wanted to continue regardless of the errors, I said "yes" ... and it worked just fine.

I get these errors on my work machine, which I 'upgraded' from 2013 to VS2015 Update 3.

I went through the same steps at home with a fresh install of VS2015 Update 3 and did NOT get these (possibly false errors).

This is not an ideal answer but I hope it helps.

Upvotes: 2

Related Questions