0

In my custom implementation of a MembershipProvider, during the Initialize method, I am constructing a number of MembershipUser objects. The MembershipUser constructor is given the name of the MembershipProvider being initialized. The problem is that this constructor causes another MembershipProvider to be constructed, recursively.

Basically, I represent users in my custom membership provider with MembershipUser objects, and I would like to load saved users from disk during Initialize.

I know I can implement a delayed load of users after Initialization, but this requires a check in each method. Is there something I am missing where I can create MembershipUsers independent of the provider?

Eric Vasilik
  • 362
  • 2
  • 14

1 Answers1

1

No you aren't missing anything. You can't do this in the Initialize method.

Joe
  • 122,218
  • 32
  • 205
  • 338
  • Ya. I have tried all sorts of things to get this to work. For example, during Initialize, I attempted to add the current MembershipProvider (with reflection, overriding the readonly aspect of the collection) to the MembershipProviderCollection (the the MembershipUser constructor would not complain). This caused a recursive instantiation of my MembershipProvider. Evidently, when accessing the MembershipProviderCollection, it reads the web.config file to create the MembershipProviders. So, I now construct the MembershipUser objects on demand, for functions which return them. – Eric Vasilik Dec 04 '13 at 03:37