【问题标题】:Updated project to framework 4.7.2 from 4.7.1 and got system.object reference errors. What gives?将项目从 4.7.1 更新到框架 4.7.2 并得到 system.object 引用错误。是什么赋予了?
【发布时间】:2021-07-24 00:15:29
【问题描述】:

在问题搜索中没有看到这种确切的情况。

我在一个网页解决方案中添加了一个 net framework 4.7.2 库,其中有 3 个项目都是 4.7.1。在我真正尝试引用 4.7.2 库中的对象之前,它运行良好。

我发现了问题,将每个项目都设置为4.7.2。

它构建得非常好。但是当我运行它时,我得到了这个错误:

Compiler Error Message: CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.


Line 82:         <img src="/images/0421-NV.png" class="img-responsive" />
Line 83:         <div class="textDiv">
Line 84:             @Html.Snippet("mysnippetname")  <<-- this line is highlighted
Line 85:         </div>
Line 86:     </div>

当我的解决方案中没有任何 netstandard 项目时,我很难理解为什么它需要 netstandard 参考。在我使用 4.7.1 之前,它也没有抱怨过。在使用 4.7.1 和编译运行之间,我没有添加任何新代码。

有什么想法吗?

编辑:我将所有内容更改为 4.7.1 进行测试,它仍然给我同样的错误。

Edit2:我确实尝试将以下内容添加到 web.config,但仍然遇到相同的错误:

   <system.web>
    <httpRuntime targetFramework="4.6.1" maxRequestLength="32768"/>
      <compilation debug="true" targetFramework="4.5">
        <assemblies>
          <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </assemblies>
    </compilation>

【问题讨论】:

标签: c# asp.net-mvc


【解决方案1】:

啊。发现了问题。实际上 2. 主项目没有包含新库的 nuget 包(这对我来说是愚蠢的),并且现有项目之一有一个旧的 nuget 包。据我所知,甚至没有使用它。我删除了这些,它现在可以工作了。

感谢大家的建议。

【讨论】:

    猜你喜欢
    • 2015-07-04
    • 1970-01-01
    • 2021-04-16
    • 1970-01-01
    • 2021-05-05
    • 2013-05-21
    • 2013-10-05
    • 2022-01-19
    • 2018-08-11
    相关资源
    最近更新 更多