简体   繁体   中英

Microsoft.Net.Http.Headers 3.0.0 does not exist but is required when upgrading to .net core 3.0

I followed the tutorial on upgrading .net core 2.2 to 3.0.

When i run my solution an error is thrown:

[CS0012] The type 'MediaTypeHeaderValue' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Net.Http.Headers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

It is thrown in my DownloadFile function:

public FileStreamResult DownloadFile(int id)
{
    ...

    return new FileStreamResult(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read), fm.ContentType);
}

The issue is, Microsoft.Net.Http.Headers, Version=3.0.0.0 does not exist in this version and i cannot find anyone else having the same problem. Since the download function is very simple and seems to be used in other projects on github i don't think it is a wrong implementation.

After a deep dive into .net core dependencies it appears that the Microsoft.Net.Http.Headers package has been moved into the .net core lib. After adding the references manually in the.csproj file i can build again.

<ItemGroup>
    ...
    <Reference Include="Microsoft.Net.Http.Headers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60"/>
</ItemGroup>

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