1

In trying to delpoy an ASP.Net MVC3 app with a custom MembershipProvider, I get this:

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

Line 43    <membership defaultProvider="NAMembershipProvider">
Line 44      <providers>
Line 45        <clear/>
Line 46        <add name="NAMembershipProvider" type="MyPage.Infrastructure.NAMembershipProvider" 
                    enablePasswordRetrieval="false" enablePasswordReset="true"
                    requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" 
                    minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
                    applicationName="/" />
Line 47      </providers>
Line 48    </membership>

How do I fix this?

MB34
  • 4,210
  • 12
  • 59
  • 110

1 Answers1

1

The common problem for this is actually not clearing your providers, which you have done.

Have you followed this: ASP.NET: This method cannot be called during the application's pre-start initialization stage

The other time this will surface is after an MVC Framework upgrade. You can get by this by simply restarting IIS (or rebooting the machine, if that is an option for you). I can't explain why this works, or what resources are being held up, but it has worked for me on at least two occasions post-upgrade.

Community
  • 1
  • 1
MisterJames
  • 3,306
  • 1
  • 30
  • 48
  • The problem was actually that I had not included my Deployable Dependencies. Everything is working now, thanks. – MB34 Sep 06 '12 at 17:34