简体   繁体   中英

Cannot reference net45 version of Microsoft.Owin Nuget package

So a couple of hours ago, I asked this question on SO: Strange Microsoft.Owin DLL issue and Nuget

I cleaned deleted some DLLs that were in the bin folder of my ASP.NET website and checked into source control. After this, I was getting an error running my website localhost:

could not load type 'Microsoft.Owin.Security.AuthenticationDescription' from assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

I figured out that my project is now referencing the 4.0 version of Microsoft.Owin, if I copy the 4.5 version of Microsoft.Owin into the bin directory of my ASP.NET MVC project, the error is fixed.

So I need a reference to Microsoft.Owin in

\packages\Microsoft.Owin.2.1.0\lib\net45

Currently my project reference is to:

\packages\Microsoft.Owin.2.1.0\lib\net40

No matter how many times I delete the reference to the net40 Microsoft.Owin.dll, close the project, reopen it, clean it, and than try Adding a new reference and browsing to \\packages\\Microsoft.Owin.2.1.0\\lib\\net45, I still get a reference to net40 version.

I have checked the packages.config:

  <package id="Microsoft.Owin" version="2.1.0" targetFramework="net45" />

The csproj file:

    <Reference Include="Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.Owin.2.1.0\lib\net45\Microsoft.Owin.dll</HintPath>
</Reference>

In my web.config:

 <compilation debug="true" targetFramework="4.5">

The Target framework for the project in the project properties is 4.5

I have uninstalled and reinstalled the Microsoft.Owin 2.1.0 Nuget package.

I even tried copying the net45 Microsoft.Owin.dll into the net40 folder for the package which resulted in the error:

Could not load file or assembly 'Microsoft.Owin' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I am using Visual Studio 2012 with tools for Visual Studio 2013 installed, when I open the Package Manage Console, I believe this is the version of Nuget I have: Package Manager Console Host Version 2.8.50313.31

If I copy the net45 version into the bin of my ASP.NET MVC Project, my error is fixed

Where is the reference to Microsoft.Owin net40 in my packages.config, Web.config or csproj, its not there, everything points to net45 libs for my packages but Microsoft.Owin points to \\packages\\Microsoft.Owin.2.1.0\\lib\\net40 no matter what I do.

愚蠢的问题,但是您是否检查了项目目标框架是否与下载的软件包匹配?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM