南希,第一个剃须刀页面不起作用 [英] Nancy, First razor page not working

查看:52
本文介绍了南希,第一个剃须刀页面不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Nancy开发第一个Razor模板,以及.cshtml的第一行...

I'm trying to get a first Razor template working with Nancy, and the first line of my .cshtml...

@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic>

给我3个构建错误,包括以下内容...

gives me 3 build errors including the following...

'NancyContext' does not contain a definition for 'ApplicationInstance' and no extension method 'ApplicationInstance' accepting a first argument of type 'NancyContext' could be found (are you missing a using directive or an assembly reference?)

一个非常奇怪的事情是我遇到了三个错误",但是它们并没有停止构建.它们显示在错误"列表中,这些类在解决方案资源管理器"中用红色下划线标出,而不是在代码窗口中.不相信我吗?屏幕截图如下...

One very weird thing is that I have three "errors", but they're not stopping the build. They show in the Error list, the classes are underlined in red in the Solution explorer but not in the code window. Don't believe me ? Screenshot follows...

我通过添加对System.Web.Helpers和System.Web.WebPages的显式引用来解决了前两个错误.剩下的错误"NancyContext"不包含"ApplicationInstance"的定义,这仍然困扰着我. ApplicationInstance是System.Web中的一种类型,对此我有一个参考.如果删除System.Web参考,该项目仍会生成.如果添加引用,我仍然会出错.

I've fixed the first two errors by adding explicit references to System.Web.Helpers and System.Web.WebPages. The remaining error, 'NancyContext' does not contain a definition for 'ApplicationInstance', is still bugging me. ApplicationInstance is a type in System.Web, for which I have a reference. If I delete the System.Web reference the project still builds. If I add the reference I still have the error.

推荐答案

我今天遇到了同样的错误,然后注意到该项目正在"Build + IntelliSense"模式下构建(如您的屏幕截图所示),转到下拉列表他们并以仅构建"模式进行构建解决了我的错误!

I got the same error today and then noticed that the project was getting build in "Build + IntelliSense" mode (as in your screenshot), going to the dropdown their and building in "Build Only" mode resolved my errors!

这篇关于南希,第一个剃须刀页面不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆