之前在Web上用是OK的.现在在控制台程序中调用.
我的App.config  <profile enabled="true" defaultProvider="SqlProfileProvider" inherits="Sof.Model.Sof.EclProfileCommon">
            <providers>
                <clear/>
                <add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="SofDBConnection" applicationName="CY2008APP"/>
            </providers>
            <!--<properties>
                <add name="Account" type="Sof.Model.Sof.EclProfileCommon" serializeAs="Binary" allowAnonymous="true"/>
            </properties>-->
        </profile>
profile的扩展Sof.Model.Sof.EclProfileCommon的定义:namespace Sof.Model.Sof
{
    /// <summary>
    /// Profile
    /// <res>继承ProfileBase的类,用来处理Profile扩展信息封装在BLL里使用的派生类</res>
    /// </summary>
    public class EclProfileCommon : ProfileBase
    {
        [SettingsAllowAnonymous(true)]
        [ProfileProvider("SqlProfileProvider")]
        public Account Account
        {
            get { return (Account)base["Account"]; }
            set { base["Account"] = value; }
        }    }
}
其他类库工程里调用这里出错了(以前用Web调用的时候,这儿是正确的) EclProfileCommon p = (EclProfileCommon)ProfileBase.Create(_userName);
错误如下:
Could not load type 'Sof.Model.Sof.EclProfileCommon' from assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.很搞不懂.为啥要去System.Web加载那个对象里.分不够再加

解决方案 »

  1.   

    YOU HO,没用过。帮你顶上……沙发,最少给5分
      

  2.   

    <!--<properties>
                    <add name="Account" type="Sof.Model.Sof.EclProfileCommon" serializeAs="Binary" allowAnonymous="true"/>
                </properties>-->这里为什么注掉啊type="Sof.Model.Sof.EclProfileCommon" 要写全名System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    这样形式的,namespace+classname,assembly name,.....Could not load type 'Sof.Model.Sof.EclProfileCommon' from assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 
    所以会报这个错,默认去system.web这个程序集中去找你的那个类啊
    等待接分,呵呵
      

  3.   

    <profile enabled="true" defaultProvider="SqlProfileProvider" inherits="Sof.Model.Sof.EclProfileCommon">这个肯定有问题要么没有这个inherits="Sof.Model.Sof.EclProfileCommon"要么把这个改成inherits="Sof.Model.Sof.EclProfileCommon, Sof"Sof是Sof.Model.Sof.EclProfileCommon所在dll的名字
    <add name="Account" type="Sof.Model.Sof.EclProfileCommon" serializeAs="Binary" allowAnonymous="true"/>
    这个也有同样的问题