【问题标题】:Umbraco CMS problem: The type 'IEnumerable<>' is defined in an assembly that is not referencedUmbraco CMS 问题:类型 'IEnumerable<>' 在未引用的程序集中定义
【发布时间】:2021-09-06 00:52:09
【问题描述】:

我刚开始使用 Umbraco CMS v.9,当我尝试查看我刚刚创建的页面时,它显示错误。
代码

@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.HomePage>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@{
    Layout = null;
}
<!DOCTYPE>
<html>
    <head>
        @Model.Name
    </head>
    <body>
        <div>
            @Model.Check
        </div>
        <div>
            
        </div>
    </body>
    <footer>
        
    </footer>
</html>

错误:
'IEnumerable' 类型是在未引用的程序集中定义的。你 必须添加对程序集 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'的引用

我一直在寻找解决方案一段时间。我遇到了很多其他遇到类似(我的假设)问题的人。我尝试在 web.config 中添加如下内容:

<compilation debug="true" targetFramework="4.5">
  <assemblies>
    <add assembly="System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"/>
  </assemblies>
</compilation>

但任何时候我重新运行,文件 web.config 都会被原始代码覆盖,删除我写的行。 (这件事真让我心烦)



如何解决这个问题?
谢谢

【问题讨论】:

  • Umbraco 9 仍处于测试阶段,因此如果您发现某些功能无法按预期工作,您应该在 GitHub (github.com/umbraco/Umbraco-CMS/issues) 上报告。 Umbraco 9 在 .NET 5 (.Net Core) 上运行,顺便说一句,也许您正试图在 .Net Framework 4.x 上运行它?

标签: content-management-system umbraco


【解决方案1】:

如果您有 web.config,我认为您使用的不是 v9。 V9 没有 web.config 文件,因为它是用 .Net Core 编写的。设置在 appsettings.json 中。

我认为你有 v8。

此外,我认为如果您的视图/类/代码未引用 System.Collections.Generic,则可能会发生您面临的问题

将以下 using 语句放在页面顶部您引用 IEnumerable 的任何位置

using System.Collections.Generic;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-16
    • 2014-08-15
    • 2016-05-01
    • 2018-01-10
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 2018-12-26
    相关资源
    最近更新 更多