简体   繁体   English

在我的web.config文件中使用kendo.mvc.ui时出现编译错误

[英]Compilation Error when using kendo.mvc.ui in my web.config file

I have an application in which I am using Kendo.Mvc.UI now I am creating another project in which I want to use Kendo.Mvc.UI so I added Kendo.Mvc.UI my bin folder see below Image for reference 我有一个正在使用Kendo.Mvc.UI的应用程序,现在我正在创建另一个要使用Kendo.Mvc.UI项目,因此我在bin文件夹中添加了Kendo.Mvc.UI请参见下图,以供参考。

and added the below code my main web.config in Pages > Namespaces 并在页面>命名空间中将以下代码添加到我的主要web.config

<add namespace="Kendo.Mvc.UI" />//the same code is working in my previous project.

and the below line in my web.config of which is in views folder 而我的web.config中的以下行位于views文件夹中

<add namespace="Kendo.Mvc.UI" /> //this is same in both the web.config 

but I am Getting the below error 但我收到以下错误

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. 编译错误描述:在编译为满足此请求所需的资源期间发生错误。 Please review the following specific error details and modify your source code appropriately. 请查看以下特定的错误详细信息,并适当地修改您的源代码。

Compiler Error Message: CS0246: The type or namespace name 'kendo' could not be found (are you missing a using directive or an assembly reference?) 编译器错误消息:CS0246:找不到类型或名称空间名称'kendo'(您是否缺少using指令或程序集引用?)

Source Error: 源错误:

Line 56: <add namespace="System.Web.Routing" /> 第56行: <add namespace="System.Web.Routing" />

Line 57: <add namespace="System.Web.WebPages" /> 第57行: <add namespace="System.Web.WebPages" />

Line 58: <add namespace="kendo.mvc.ui" /> 第58行: <add namespace="kendo.mvc.ui" />

Line 59: </namespaces> 第59行: </namespaces>

Line 60: </pages> 第60行: </pages>

Using a project I currently have the following should work: in the main web.config 使用一个项目,我目前有以下工作:在主web.config

The directive should be here: 该指令应在此处:

  <system.web>

   ...All other options removed for brevity....
    <pages>
      <namespaces>
        <add namespace="Kendo.Mvc.UI" />
      </namespaces>
    </pages>
  </system.web>

then in the web.config under your Views folder it should look like this: 然后在Views文件夹下的web.config中,它应如下所示:

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />

        <add namespace="Kendo.Mvc.UI" />

      </namespaces>
    </pages>
  </system.web.webPages.razor>

Which based on your first image looks correct. 根据您的第一张图片来看哪个看起来正确。

Assuming you have the web.config files configured correctly then intellisense should kick in after a shutdown and reopen of the project (if it doesn't recognise it straight away) when you type something like @Html.Kendo().<control here> 假设您已正确配置了web.config文件,则在键入@Html.Kendo().<control here>类的内容时,intellisense应该在关闭并重新打开项目后启动(如果无法立即识别出该项目@Html.Kendo().<control here>

Assuming you have added the reference to the Kendo.Mvc and Kendo.Mvc.Export dll's into the project. 假设您已将Kendo.MvcKendo.Mvc.Export dll的引用添加到项目中。

Failing this working have you tried to use the Telerik Kendo UI for MVC plugin for Visual Studio to upgrade the project as this may also help resolve this issue for you. 如果您尝试使用Telerik Kendo UI for Visual Studio的MVC插件升级项目失败,则这可能会帮助您解决此问题。 If you don't have this option this try downloading it either package updater or via the progress updater software for Telerik. 如果没有此选项,请尝试使用软件包更新程序或通过Telerik的进度更新程序软件下载它。

As a side note I noticed in your image that you have a file System.Web.Http.Cors.xml which is in errored state. 附带说明,我在您的图像中注意到您有一个处于错误状态的文件System.Web.Http.Cors.xml This may be preventing your project from building correctly which could be impacting the dll for kendo from being loaded correctly. 这可能会阻止您的项目正确构建,这可能会影响kendo的dll正确加载。

Personally when adding/referencing dll's in a project I prefer to add the files into a lib folder that sits alongside the project rather than adding the files into a bin folder as the bin folder is usually excluded from source control check-ins. 就个人而言,在项目中添加/引用dll时,我更喜欢将文件添加到项目旁边的lib文件夹中,而不是将文件添加到bin文件夹中,因为bin文件夹通常不包括在源代码管理签入中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM