76

I am working on an Asp.Net MVC 4 Application in which I am using SignalR 2.0.1 and I Mapped it using Owin Startup class and it worked fine at first.

All of a sudden when I tried to rebuild my app it said that the type are namespace IAppbuilder could not be found.

Following is my start up class

using Microsoft.Owin;
using Owin;
using WhiteBoardApp;

namespace WhiteBoardApp
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }
}

I have installed Owin package too, and for some reasons I could not find Owin Startup class so I just added a normal class and included all the references that are needed. May I know where I am making a mistake

Bruno
  • 4,685
  • 7
  • 54
  • 105
DoIt
  • 3,270
  • 9
  • 51
  • 103

9 Answers9

157

Try to use Package Manage Console and do

Update-Package Owin -Reinstall
scottt732
  • 3,877
  • 2
  • 21
  • 23
  • 2
    A user suggested an edit to remove the -Reinstall flag. It's probably worth explaining the distinction. The -Reinstall flag will cause NuGet to re-apply the same version of the package that you already have installed. It's like a Repair operation. Generally it will already be in the packages folder and won't need to download. Without this flag, the operation will update the package to the latest version, but only if there is a newer version. Also, this may impact other packages that depend on it. If you already have the latest version installed, I don't think this will do anything. – scottt732 Apr 11 '14 at 22:22
  • I had the same issue. I upgraded to the latest version of SignalR/Owin through nuget. IAppBuilder was not getting resolved. I did the prescribed remedy and the error is gone. BUT.., it pulled down Owin 1.0. Shouldn't we be using the latest and greatest here? – JohnB Apr 23 '14 at 22:23
  • The Owin package basically contains interfaces defined in the OWIN spec and I as far as I can tell (from owin.org and nuget.org) it's still at 1.0. The Microsoft.Owin package is Microsoft's implementation of the OWIN specification. It's nearing v3.0 but it still depends on Owin 1.0. The Update-Package Owin -Reinstall command causes Owin and any packages that depend on it to get reinstalled. SignalR and WebAPI indeirectly depend on Microsoft.Owin and Owin. After this command gets your builds working again, feel free to update any packages. – scottt732 Apr 24 '14 at 01:55
29

I was having similar issue. But instead Owin, problem was causing Microsoft.Owin, obviously

Update-Package Owin -Reinstall

Didn't work, neither did Update-Package Owin

BUT

Install-Package Microsoft.Owin

did work fine for me, thanks.

Иво Недев
  • 1,570
  • 1
  • 20
  • 33
9

The IAppBuilder interface is found under Owin package. Just add a reference in your class file:

using Owin;

And rebuild. Your project will pick this up.

I have no idea why VS didn't pick this up, but it didn't. Once I added this reference to my project, then everything fell into place.

chris smith
  • 161
  • 2
  • 3
6

I encountered the same problem while building my project. Here are the steps that helped fix my problem:

  1. Go to Solution Explorer and look for your project
  2. Under your project, expand the References; You should see warnings on the problematic reference
  3. Right click References and open Manage NuGet Packages
  4. Search the name of problematic reference i.e. Microsoft.Owin; After loading it shows that it is already installed (It is, but it installed incorrectly. Checking the properties > version at step 2 shows 0.0.0.0)
  5. Check Force uninstall, even if there are dependencies on it
  6. Uninstall
  7. Install
  8. Build and run the project

Problems

Cannot install Microsoft.Web.Infrastructure because it already exists in the packages folder. Rolling back...

  1. Go to your project folder and look for packages
  2. Find the problematic package i.e. Microsoft.Web.Infrastructure
  3. Delete the folder
  4. Resume from step 7

Alternatives

Here are the alternatives I've read about to fix this kind of problem.

  • Clean and Rebuild Project / Solution
  • Restart Visual Studio
  • Restart PC

Good luck.

dsapalo
  • 1,819
  • 2
  • 19
  • 37
2

My Visual Studio 2013 for some reason didn't realize that the references paths existed. The yellow exclamation mark in front of the references was shown for all the added packages. I checked ../packages/ but all files existed, i also opened the .csproj file which referenced the correct paths.

Closing and opening the solution returned quite a lot of errors, and could not load the projects included in the solution.

Restarting Visual Studio 2013 saved the day for some unexplained reason.

Crypth
  • 1,576
  • 18
  • 32
1

My following using's equivalent in F# present a problem of hiding the IAppBuilder. It turns out that the Owin stipulation was being interpreted as an incomplete System.Web.Http.Owin reference, even though the Owin.dll providing the Owin namespace was referenced.

open System.Net.Http
open System.Web.Http
open Microsoft.Owin
open Owin

The problem was resolved by rearranging the usings as follows:

open Microsoft.Owin
open Owin
open System.Net.Http
open System.Web.Http

...granted, this may be a bug peculiar to the F# compiler and name conflicts are handle better in C# and elsewhere.

George
  • 2,451
  • 27
  • 37
0

In my case, I had moved around the project folders and the location of the vs solution file (.sln). Once I was done with re-adding the projects, there was a packages folder on the solution level and one was left in a project sub folder. This way, in that project, the relative package folder links in the .csproj file got messed up.

The reinstallation or other tips regarding the nuget package manager in this thread were helpful. I noticed, that after I reinstalled a few packages, in my git source code diff, the path of the packages folder was changed within the csproj file.

Before

<HintPath>packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath>

After

<HintPath>..\packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath>

So, if you run in the same issue and you have a lot of nuget packages, it might be easier to close the whole solution, open the csproj file(s) in a text editor like vscode and fix the relative links with search and replace. Then just save, close, reopen solution in VS and restore nuget packages. That should do the trick. (In any case, you should delete the local packages folder on the project level, so that the project really fails, if it does not get the right packages.)

AIsmaili
  • 81
  • 2
  • 7
0

It's an ordering issue.

using Microsoft.Owin;
using Owin;

Leads to Microsoft.Owin to be defined first, then Owin is found under already imported Microsoft namespace. If you mouse over Owin of using Owin you should see it was resolved to Microsoft.Owin again and furthermore IDE will gray out using Owin as redundant unused reference.

Do:

using global::Owin;

Which clarifies for the compiler not to look for Owin under already defined namespaces (e.g. Microsoft. namespace).

David Burg
  • 1,064
  • 12
  • 14
-1

http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr

Check for the visual studio you are using You can find the following comment

Note: If you are using Visual Studio 2012, the SignalR Hub Class (v2) template will not be available. You can add a plain Class called ChatHub instead.

Also Note: If you are using Visual Studio 2012, the OWIN Startup Class template will not be available. You can add a plain Class called Startup instead.