gpt4 book ai didi

c# - Microsoft.Net.Http.Headers 3.0.0 不存在但升级到 .net core 3.0 时需要

转载 作者:行者123 更新时间:2023-11-30 22:52:16 25 4
gpt4 key购买 nike

我关注了the tutorial关于将 .net core 2.2 升级到 3.0。

当我运行我的解决方案时抛出一个错误:

[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'.

它是在我的 DownloadFile 函数中抛出的:

public FileStreamResult DownloadFile(int id)
{
...

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

问题是,Microsoft.Net.Http.Headers, Version=3.0.0.0 在此版本中不存在,我找不到其他有同样问题的人。由于下载功能非常简单,并且似乎在github上的其他项目中使用过,所以我不认为这是一个错误的实现。

最佳答案

在深入研究 .net 核心依赖项后,Microsoft.Net.Http.Headers 包似乎已移至 .net 核心库中。在 .csproj 文件中手动添加引用后,我可以再次构建。

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

关于c# - Microsoft.Net.Http.Headers 3.0.0 不存在但升级到 .net core 3.0 时需要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58302134/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com