The type or namespace IAppBuilder could not be found(missing using a directive pr an assembly reference)

后端 未结 9 1491
故里飘歌
故里飘歌 2020-12-08 18:33

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

相关标签:
9条回答
  • 2020-12-08 18:34

    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.

    0 讨论(0)
  • 2020-12-08 18:35

    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.

    0 讨论(0)
  • 2020-12-08 18:46

    Try to use Package Manage Console and do

    Update-Package Owin -Reinstall
    
    0 讨论(0)
  • 2020-12-08 18:50

    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).

    0 讨论(0)
  • 2020-12-08 18:52

    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.

    0 讨论(0)
  • 2020-12-08 18:52

    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.

    0 讨论(0)
提交回复
热议问题