How do I call Initialize on a custom MembershipProvider?

前端 未结 8 747
死守一世寂寞
死守一世寂寞 2020-12-08 08:17

I have read through all the related questions, but I still unable to get the right solution for some reason, something is not right on my side, but not sure what\'s causing

8条回答
  •  误落风尘
    2020-12-08 08:57

    Custom Membership provider is initialized automatically and it is not intended to do so manually.

    In my implementation, there is the Initialize metod like below:

    public override void Initialize(string name, NameValueCollection config)
    {
        if (config == null)
            throw new ArgumentNullException("config");
    
    
        // Initialize the abstract base class.
        base.Initialize(name, config);
    }
    

    Keep in mind, that the base.Initialize method is in ProviderBase class which has the following exceptions defined:

    Exceptions:

    • System.ArgumentNullException: The name of the provider is null.
    • System.ArgumentException: The name of the provider has a length of zero.

    • System.InvalidOperationException: An attempt is made to call System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection) on a provider after the provider has already been initialized.

    Isn't the last exception the one you get?

提交回复
热议问题