【问题标题】:Type or namespace name does not exist类型或命名空间名称不存在
【发布时间】:2017-11-01 03:41:22
【问题描述】:

我正在使用下面的代码:

using CMS.DataEngine;
using CMS.DocumentEngine;

namespace Fort.CMS.CMSPages
{
    public partial class CreatePage : System.Web.UI.Page
    {
        #region "Variables"

        private CMS.DocumentEngine.TreeNode mNode;
        private TreeProvider mTree;

出现错误:private CMS.DocumentEngine.TreeNode mNode;

错误:

类型或命名空间名称“DocumentEngine”不存在于 命名空间“Fort.CMS”

此处的 DocumentEngine 无法识别。

但如果我们删除命名空间,它会起作用。

namespace Fort.CMS.CMSPages
{}

【问题讨论】:

  • CMS.DocumentEngine 是不是与另一个库不同的命名空间?
  • 不,不是,但命名空间存在冲突,因此我们需要放置命名空间的绝对路径
  • 其实YES CMS.DocumentEngine是Kentico库中的命名空间..

标签: c# asp.net .net namespaces kentico


【解决方案1】:

我认为有命名空间冲突。使用如下

using CMS.DataEngine;
using DE=CMS.DocumentEngine;

namespace Fort.CMS.CMSPages
{
    public partial class CreatePage : System.Web.UI.Page
    {
        #region "Variables"

        private DE.TreeNode mNode;
        private TreeProvider mTree;

【讨论】:

  • 永远不要只发布没有解释的代码,这对任何人都没有帮助。
猜你喜欢
  • 1970-01-01
  • 2012-06-19
  • 1970-01-01
  • 2012-05-28
  • 1970-01-01
  • 1970-01-01
  • 2014-11-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多