首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于C#的命名空间,多谢

2012-03-16 
关于C#的命名空间,谢谢!我自己学着写的这个,但是如果加上命名空间,就会出现“未能从程序集“App_Code.rdirds

关于C#的命名空间,谢谢!
我自己学着写的这个,但是如果加上命名空间,就会出现

“未能从程序集“App_Code.rdirds3h,   Version=0.0.0.0,   Culture=neutral,   PublicKeyToken=null”中加载类型“EmployeeDA”。”

这个错误。

如果去掉命名空间,就没问题!

 

msdn上说命名空间不指定的话,也会有个默认的命名空间。

为什么指定的命名空间会发生错误?

 

谢谢!

代码如下:


using   System;
using   System.Text;
using   System.Web;
using   SMS.MySqlHelper;

namespace   SMS.DataAccess
{
        /// <summary>
        ///
        /// </summary>
        public   interface   IEntityDA
        {
        }

        public   class   DataAccessFactory
        {
                public   IEntityDA   CreateEntityDA(string   type)
                {
                        IEntityDA   da   =   null;
                      //   try
                      //   {
                                Type   currentType   =   Type.GetType(type,   true);

                                da   =   (IEntityDA)Activator.CreateInstance(currentType);
                      //   }
                      //   catch   (TypeLoadException   e)
                      //   {
                    //             System.Web.HttpContext.Current.Response.Write( "该对象未被定义,详细信息 <br   /> "   +   e.Message);
                      //   }
                        return   da;
                }
        }

        public   class   MemberDA   :   IEntityDA
        {
                public   MemberDA()
                {
                        System.Web.HttpContext.Current.Response.Write( "Member ");
                }
        }

        public   class   EmployeeDA   :   IEntityDA
        {
                public   string   name;

                public   EmployeeDA()
                {
                        name   =   "admin ";


                        System.Web.HttpContext.Current.Response.Write(name);
                }
        }
}



[解决办法]
IEntityDA da = null ------ 原因所在?

热点排行