5
我使用Nancyfx和Visual Studio 2012中的Razor视图引擎在C#中创建黑色插孔程序。Visual Studio工作室Intelisense可以工作,但是我得到了这些Razor编译错误。我已经尝试在app/web.config中指定名称空间,但没有结果。使用NancyFX的Razor编译错误
Error Details
Error compiling template: Views/Game.cshtml
Errors:
[CS0246] Line: 1 Column: 11 - The type or namespace name 'Black_Jack' could not be found (are you missing a using directive or an assembly reference?)
[CS0246] Line: 24 Column: 73 - The type or namespace name 'Black_Jack' could not be found (are you missing a using directive or an assembly reference?)
Details:
@using Black_Jack.Models
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<Game>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
@{
foreach(var player in @Model.Players.players)
{
foreach(var card in player.Hand.Cards)
{
<p>@card.Name</p>
}
}
}
</body>
</html>
谢谢!我早些时候查看了链接,它不包含项目本身的程序集名称。添加它给了我另一个错误:'无法投射'System.Dynamic.ExpandoObject'类型的对象来键入'Black_Jack.Models.Game''。我重构我的代码,不发送ExpandoObject到视图,它的工作。但是,这也使web.config中的assemblyname条目变得多余。奇怪的。 – 2013-03-05 13:46:27