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

后端 未结 9 1492
故里飘歌
故里飘歌 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:59

    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.

    0 讨论(0)
  • 2020-12-08 19:00

    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.

    0 讨论(0)
  • 2020-12-08 19:00

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

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