c# - Razor HTML Helpers 在 Nop Commerce 插件中给出智能感知错误

标签 c# asp.net asp.net-mvc razor nopcommerce

我正在为 Nop Commerce 编写插件,但我的 HTML 助手给我智能感知错误。我用红线强调了它们和错误:

无法使用功能“扩展方法”,因为它不是 ISO-2 C# 语言规范的一部分

无法使用功能“lambda 表达式”,因为它不是 ISO-2 C# 语言规范的一部分

这是我的代码:

@{
    Layout = "";
}
@model Nop.Plugin.Widgets.HelloWorld.Models.ConfigurationModel
@using Nop.Web.Framework;
@Html.Action("StoreScopeConfiguration", "Setting", new { area = "Admin" })
@using (Html.BeginForm())
{
    <fieldset>
        <legend><strong>Hello World Configuration</strong></legend>
        <table class="adminContent">
            <tr>
                <td class="adminTitle">
                @Html.OverrideStoreCheckboxFor(model => model.Greeting_OverrideForStore, model => model.Greeting, Model.ActiveStoreScopeConfiguration)
                    @Html.NopLabelFor(model => model.Greeting):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.Greeting)
                    @Html.ValidationMessageFor(model => model.Greeting)
                </td>
            </tr>
            <tr>
                <td class="adminTitle">
                    @Html.OverrideStoreCheckboxFor(model => model.Name_OverrideForStore, model => model.Name, Model.ActiveStoreScopeConfiguration)
                    @Html.NopLabelFor(model => model.Name):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.Name)
                    @Html.ValidationMessageFor(model => model.Name)
                </td>
            </tr>
        </table>
    </fieldset>
    <br />
    <table class="adminContent">
        <tr>
            <td colspan="2">
                <input type="submit" name="save" class="k-button" value="@T("Admin.Common.Save")" />
            </td>
        </tr>
    </table>
}

我的屏幕看起来像:

enter image description here

我已经寻找了几个小时的答案,但没有找到真正有效的答案。该项目是一个代码库,与解决方案的其余部分一样在 ASP.NET 4.5.1 上运行。我构建时没有错误。我是否缺少引用或使用声明?我不确定发生了什么。

最佳答案

我能够使它工作(使用 VS2013)的唯一方法是将类库项目转换为 MVC 项目:

  1. <PropertyGroup> , 添加 < ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}< /ProjectTypeGuids>
  2. 在底部添加另一个导入:< Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

    当然要删除 中的多余空间,没有它们就不能正确发布。 Microsoft 在这里发布了一个当前错误:https://connect.microsoft.com/VisualStudio/feedback/details/912301/intellisense-for-razor-in-class-libraries-not-working

关于c# - Razor HTML Helpers 在 Nop Commerce 插件中给出智能感知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24175743/

相关文章:

android - .net web 服务在数据开头返回 NULL 对象

asp.net - 使用 VB.NET 从纯字符串解析 URL ?a=b 参数

asp.net-mvc - 使用 bootstrap 和 kendo-bootstrap 排序 CSS 样式表

c# - 在 MVC 的 ViewModel 中仅使用 Model 的一些属性

c# - 如何在 nuget 包中包含单独添加的 system.configuration dll

c# - 在 IIS 7.0 中对 html 页面的未授权访问错误

c# - Paypal IPN 示例代码没有 ActionResult。如果没有 View ,我将如何提供 URL?

c# - 需要加速转换时间戳的 C# 应用程序

javascript - 验证(CSS 3.0): 'text-overflow' is not a known CSS property name

asp.net-mvc - 如何提交本地jqgrid数据和表单输入元素