日期:2014-05-18  浏览次数:20511 次

找不到类型或命名空间名称“ProfileCommon” 是否缺少 using 指令或程序集引用?
我是建立的WEB应用程序,不是网站.
Profile配置如下:        
            <profile   defaultProvider= "TrafficManageProfileProvider ">
                <providers>
                    <remove   name= "AspNetSqlProfileProvider "/>
                    <add   name= "TrafficManageProfileProvider "   type= "System.Web.Profile.SqlProfileProvider "
                        connectionStringName= "TrafficManage "   applicationName= "TrafficManage "       />
                </providers>
                <properties>
                    <add   name= "RealName "   type= "string "   />
                    <add   name= "Theme "   type= "string "   defaultValue= "default "/>
                </properties>
            </profile>
Webconfig中的其它配置均正常.
ProfileCommon出不来,Profile后打一点,也没有RealName等出来,类关系图中找不到   ProfileCommon,请各位高手帮忙看下看,找了两天也没有找到原因.

------解决方案--------------------
现在VS2005 Web Application Project 1.0英文版是不支持动态建立Profile对象,如果使用的项目是Web Applicaiton Project则不能发现Profile对象
解决的方法有两种
********************************************************************************
一、自己Coding ProfileCommon类
public class ProfileCommon : System.Web.Profile.ProfileBase
{
[SettingsAllowAnonymous(true)]
public string TestString
{
get { return base[ "TestString "] as string; }
set { base[ "TestString "] = value; }
}
}
在Web.config文件中要这样定义
<profile defaultProvider= "SqlServers " enabled= "true " inherits= "ProfileCommon " />
Code-Behind中
ProfileCommon profile = (ProfileCommon)HttpContext.Current.Profile;
profile.TestString = "Test ";