问题
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>
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...
Update
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.
回答1:
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!
回答2:
All I can say is that ApplicationInstance
is not a Nancy type. Perhaps you are missing a namespace or assembly include? https://github.com/NancyFx/Nancy/wiki/Razor-View-Engine
Other than that, you are going to have to share a lot more information or there's not much to go on
来源:https://stackoverflow.com/questions/36353303/nancy-first-razor-page-not-working