首页 新闻 会员 周边

请问有谁重定那ProfileProvider

0
悬赏园豆:5

请问有谁重定那ProfileProvider,想请教一个啊,

我的代码是这样的:

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Configuration.Provider;
using System.Linq;
using System.Web;
using System.Web.Profile;

/// <summary>
///DefinePro 的摘要说明
/// </summary>
public class DefinePro : ProfileProvider {
    public DefinePro() {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }
    private string _AppName;
  private string _sqlConnectionString;
    private int _SchemaVersionCheck;
    private int _CommandTimeout;
    public override string Name {
        get {
            return "DefinePro";
        }
    }
    public override void Initialize(string name, NameValueCollection config) {
        // Remove CAS in sample: HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, SR.Feature_not_supported_at_this_level);
        if (config == null)
            throw new ArgumentNullException("config");
        if (name == null || name.Length < 1)
            name = "DefinePro";
        if (string.IsNullOrEmpty(config["description"])) {
            config.Remove("description");
          //  config.Add("description", SR.GetString(SR.ProfileSqlProvider_description));
        }
        base.Initialize(name, config);

        _SchemaVersionCheck = 0;

        string temp = config["connectionStringName"];
        if (temp == null || temp.Length < 1)
           // throw new ProviderException(SR.GetString(SR.Connection_name_not_specified));
      //  _sqlConnectionString = SqlConnectionHelper.GetConnectionString(temp, true, true);
        if (_sqlConnectionString == null || _sqlConnectionString.Length < 1) {
          //  throw new ProviderException(SR.GetString(SR.Connection_string_not_found, temp));
        }

        _AppName = config["applicationName"];
        if (string.IsNullOrEmpty(_AppName))
          //  _AppName = SecUtility.GetDefaultAppName();

        if (_AppName.Length > 256) {
          //  throw new ProviderException(SR.GetString(SR.Provider_application_name_too_long));
        }

      //  _CommandTimeout = SecUtility.GetIntValue(config, "commandTimeout", 30, true, 0);

        config.Remove("commandTimeout");
        config.Remove("connectionStringName");
        config.Remove("applicationName");
        if (config.Count > 0) {
            string attribUnrecognized = config.GetKey(0);
          //  if (!String.IsNullOrEmpty(attribUnrecognized))
               // throw new ProviderException(SR.GetString(SR.Provider_unrecognized_attribute, attribUnrecognized));
        }

    }

    public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate) {
        throw new NotImplementedException();
    }

    public override int DeleteProfiles(string[] usernames) {
        throw new NotImplementedException();
    }

    public override int DeleteProfiles(ProfileInfoCollection profiles) {
        throw new NotImplementedException();
    }

    public override ProfileInfoCollection FindInactiveProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords) {
        throw new NotImplementedException();
    }

    public override ProfileInfoCollection FindProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) {
        throw new NotImplementedException();
    }

    public override ProfileInfoCollection GetAllInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords) {
        throw new NotImplementedException();
    }

    public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) {
        throw new NotImplementedException();
    }

    public override int GetNumberOfInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate) {
        throw new NotImplementedException();
    }

    public override string ApplicationName {
        get {
            throw new NotImplementedException();
        }
        set {
            throw new NotImplementedException();
        }
    }

    public override System.Configuration.SettingsPropertyValueCollection GetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection collection) {
        throw new NotImplementedException();
    }

    public override void SetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyValueCollection collection) {
        using (TestDataContext dbs = new TestDataContext()) {
            var singelUser = dbs.Users.Single(c => c.UserName == context["UserName"].ToString());
            if (singelUser != null) {
                singelUser.QQ = collection["QQ"].PropertyValue.ToString();
                singelUser.Sex = collection["sex"].PropertyValue.ToString();
                dbs.SubmitChanges();
            }

 

        }
    }
}

但是出错:

配置错误

说明: 在处理向该请求提供服务所需的配置文件时出错。请检查下面的特定错误详细信息并适当地修改配置文件。

分析器错误消息: 未将对象引用设置到对象的实例。

源错误:

行 38:             <providers>
行 39:                 <clear/>
行 40:                 <add name="DefinePro" type="DefinePro" connectionStringName="TestConnectionString"/>
行 41:                 <!--关键就是这里的type="DefinePro" 就可以使用了 -->
行 42:             </providers>

源文件: F:\you\MyMemberShip\web.config    行: 40


版本信息: Microsoft .NET Framework 版本:2.0.50727.3053; ASP.NET 版本:2.0.50727.3053

MR_Wang的主页 MR_Wang | 初学一级 | 园豆:200
提问于:2009-05-04 17:52
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册