剃刀未编译 System.Diagnostics.Tracing.EventLevel
Razor not compiling System.Diagnostics.Tracing.EventLevel
我正在尝试编写一个网页,该网页将根据与该项目关联的严重级别切换该项目的颜色。我在 mscorlib DLL 中使用 System.Diagnostics.Tracing.EventLevel 枚举。
当我尝试编译此页面时,出现编译错误:
错误 CS0234:命名空间 'System.Diagnostics' 中不存在类型或命名空间名称 'Tracing'(是否缺少程序集引用?)
代码本身在 .cshtml 文件中看起来很好,intellisense 可以检测命名空间和类型并适当地完成所有内容,只是无法编译。如果我在 Razor 视图中的类型上按 F12,它会将我带到 mscorlib DLL 信息。网站项目没有缺少对 mscorlib 的引用,因为它是默认情况下所有此类项目都包含的默认库(当我尝试 'add' 它到项目引用文件夹时,VS 告诉我这一点)。我做错了什么?
@model NMCOnlineServices.Website.Areas.HEI.Models.EditRecordViewModel
@using NMCOnlineServices.Website.Areas.HEI.Extensions
@functions{
public String GetColour(System.Diagnostics.Tracing.EventLevel level)
{
switch (level)
{
case System.Diagnostics.Tracing.EventLevel.Critical:
case System.Diagnostics.Tracing.EventLevel.Error:
return "Red";
case System.Diagnostics.Tracing.EventLevel.Warning:
return "Amber";
default:
return "Black";
}
}
}
//More view stuff here, compiler bombs out on the GetColour() declaration
所有正在使用的项目都针对 .NET 4.5。项目的总体 web.config 包含以下行:
<compilation debug="true" targetFramework="4.0">
修复方法是将其更改为:
<compilation debug="true" targetFramework="4.5">
我正在尝试编写一个网页,该网页将根据与该项目关联的严重级别切换该项目的颜色。我在 mscorlib DLL 中使用 System.Diagnostics.Tracing.EventLevel 枚举。
当我尝试编译此页面时,出现编译错误: 错误 CS0234:命名空间 'System.Diagnostics' 中不存在类型或命名空间名称 'Tracing'(是否缺少程序集引用?)
代码本身在 .cshtml 文件中看起来很好,intellisense 可以检测命名空间和类型并适当地完成所有内容,只是无法编译。如果我在 Razor 视图中的类型上按 F12,它会将我带到 mscorlib DLL 信息。网站项目没有缺少对 mscorlib 的引用,因为它是默认情况下所有此类项目都包含的默认库(当我尝试 'add' 它到项目引用文件夹时,VS 告诉我这一点)。我做错了什么?
@model NMCOnlineServices.Website.Areas.HEI.Models.EditRecordViewModel
@using NMCOnlineServices.Website.Areas.HEI.Extensions
@functions{
public String GetColour(System.Diagnostics.Tracing.EventLevel level)
{
switch (level)
{
case System.Diagnostics.Tracing.EventLevel.Critical:
case System.Diagnostics.Tracing.EventLevel.Error:
return "Red";
case System.Diagnostics.Tracing.EventLevel.Warning:
return "Amber";
default:
return "Black";
}
}
}
//More view stuff here, compiler bombs out on the GetColour() declaration
所有正在使用的项目都针对 .NET 4.5。项目的总体 web.config 包含以下行:
<compilation debug="true" targetFramework="4.0">
修复方法是将其更改为:
<compilation debug="true" targetFramework="4.5">