This method cannot be called during the application's pre-start initialization phase.

Sep 8, 2012 at 5:51 PM

Hi Guys,

I've followed the instructions to enable the code first membership provider but keep getting the error:

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: This method cannot be called during the application's pre-start initialization phase.

Source Error:

Line 41:     <membership defaultProvider="CodeFirstMembershipProvider">
Line 42:       <providers>
Line 43:         <add name="CodeFirstMembershipProvider" type="CodeFirstMembershipSharp.CodeFirstMembershipProvider" connectionStringName="DataContext" />
Line 44:       </providers>
Line 45:     </membership>

If I then add the following to the appSettings in the web.config

<add key="enableSimpleMembership" value="false" />

 The code runs fine, but I would then need to impliment all of the abstract methods for the ExtendedMembershipProvider. Any ideas what I'm doing wrong to get this working with simple membership?

Cheers,

 Kevin

 

 

Coordinator
Sep 8, 2012 at 6:27 PM

Are you using this with ASP.NET Webpages? If so then Simple Membership is enabled by default, you need to disable it in order to use CodeFirstMembership, both cannot run in the same time.

If you wish to use some of the methods of SimpleMembership you can download ASP.NET source code, the methods are located in the WebMatrix.Data namespace I believe, and copy the methods over, both SimpleMembership and CodeFirstMembership use same techniques even the filenames are same.

Sep 8, 2012 at 7:33 PM

Thanks for your quick feedback, I'm using ASP.net MVC 4 Web Application and indeed simple membership is enabled by default. Only by turning this off can I get passed the error above. I'll retest with MVC 3 and see if it's specific to the latest MVC version. Failing that I'll create the usual EF classes for extra profile fields and tip toe around the standard provider for now.

Cheers