2012-03-20 5 views
-3

저는 현재 첫 MVC 애플리케이션을 작성 중이며 새 MembershipProvider를 작성하고 있지만 일부 오류는 발생하지 않습니다.Obscure가 컴파일 오류를 구현하지 않습니다.

public class ProfileProvider : MembershipProvider 
    { 
     protected NameValueCollection Config = null; 
     protected new String Name = null; 
     protected String _PasswordStrengthRegularExpression = ""; 
     protected int _MinRequiredNonAlphanumericCharacters = 0; 
     protected int _MinRequiredPasswordLength = 0; 
     protected String _PasswordFormat = ""; 
     protected Boolean _RequiresUniqueEmail = false; 
     protected int _PasswordAttemptWindow = 0; 
     protected int _MaxInvalidPasswordAttempts = 0; 
     protected String _ApplicationName = ""; 
     protected Boolean _RequiresQuestionAndAnswer = false; 
     protected Boolean _EnabledPasswordReset = false; 
     protected Boolean _EnablePasswordRetrieval = false; 

     protected new String PasswordStrengthRegularExpression 
     { 
      get 
      { 
       return this._PasswordStrengthRegularExpression; 
      } 
      set 
      { 
       this._PasswordStrengthRegularExpression = value; 
      } 
     } 
     public new int MinRequiredNonAlphanumericCharacters 
     { 
      get 
      { 
       return this._MinRequiredNonAlphanumericCharacters; 
      } 
      set 
      { 
       this._MinRequiredNonAlphanumericCharacters = value; 
      } 
     } 
     public new int MinRequiredPasswordLength 
     { 
      get 
      { 
       return _MinRequiredPasswordLength; 
      } 
      set 
      { 
       this._MinRequiredPasswordLength = value; 
      } 
     } 
     public new String PasswordFormat 
     { 
      get 
      { 
       return this._PasswordFormat; 
      } 
      set 
      { 
       this._PasswordFormat = value; 
      } 
     } 
     public new Boolean RequiresUniqueEmail 
     { 
      get 
      { 
       return _RequiresUniqueEmail; 
      } 
      set 
      { 
       this._RequiresUniqueEmail = value; 
      } 
     } 
     public new int PasswordAttemptWindow 
     { 
      get 
      { 
       return this._PasswordAttemptWindow; 
      } 
      set 
      { 
       this._PasswordAttemptWindow = value; 
      } 
     } 
     public new int MaxInvalidPasswordAttempts 
     { 
      get 
      { 
       return this._MaxInvalidPasswordAttempts; 
      } 
      set 
      { 
       this._MaxInvalidPasswordAttempts = value; 
      } 
     } 
     public new String ApplicationName 
     { 
      get 
      { 
       return this._ApplicationName; 
      } 
      set 
      { 
       this._ApplicationName = value; 
      } 
     } 
     public new Boolean RequiresQuestionAndAnswer 
     { 
      get 
      { 
       return this._RequiresQuestionAndAnswer; 
      } 
      set 
      { 
       this._RequiresQuestionAndAnswer = value; 
      } 
     } 
     public new Boolean EnablePasswordReset 
     { 
      get 
      { 
       return this._EnabledPasswordReset; 
      } 
      set 
      { 
       this._EnabledPasswordReset = value; 
      } 
     } 
     public new Boolean EnablePasswordRetrieval 
     { 
      get 
      { 
       return this._EnablePasswordRetrieval; 
      } 
      set 
      { 
       this._EnablePasswordRetrieval = value; 
      } 
     } 

그리고 여기 내 컴파일 오류가 있습니다 : 여기 내 코드입니다

Error 5 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.RequiresUniqueEmail.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 10 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.RequiresQuestionAndAnswer.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 1 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.PasswordStrengthRegularExpression.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 4 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.PasswordFormat.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 6 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.PasswordAttemptWindow.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 3 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.MinRequiredPasswordLength.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 2 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.MinRequiredNonAlphanumericCharacters.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 7 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.MaxInvalidPasswordAttempts.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 12 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.EnablePasswordRetrieval.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 11 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.EnablePasswordReset.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 8 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.ApplicationName.set' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 9 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.ApplicationName.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 

오류가 나에게 의미가; '이봐, 당신은이 물건이 필요해.'하지만 사실은 그 물건을 더했다는 것입니다. 어떤 생각이라도 감사합니다. 미리 감사드립니다.

::: 편집 :::

내가 '무시'와 '새로운'교체 ​​시도와 유사한 보트에 종료 한 것을 언급하는 것을 잊었다. 여기 내 오류는 변화이다 : 당신은 당신의 방법에 override 대신 new을 사용한다

Error 7 'EmptyMVC.Controllers.ProfileProvider.RequiresUniqueEmail.set': cannot override because 'System.Web.Security.MembershipProvider.RequiresUniqueEmail' does not have an overridable set accessor C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 78 13 EmptyMVC 
Error 10 'EmptyMVC.Controllers.ProfileProvider.RequiresQuestionAndAnswer.set': cannot override because 'System.Web.Security.MembershipProvider.RequiresQuestionAndAnswer' does not have an overridable set accessor C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 122 13 EmptyMVC 
Error 3 'EmptyMVC.Controllers.ProfileProvider.PasswordStrengthRegularExpression': cannot change access modifiers when overriding 'public' inherited member 'System.Web.Security.MembershipProvider.PasswordStrengthRegularExpression' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 28 35 EmptyMVC 
Error 6 'EmptyMVC.Controllers.ProfileProvider.PasswordFormat': type must be 'System.Web.Security.MembershipPasswordFormat' to match overridden member 'System.Web.Security.MembershipProvider.PasswordFormat' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 61 32 EmptyMVC 
Error 8 'EmptyMVC.Controllers.ProfileProvider.PasswordAttemptWindow.set': cannot override because 'System.Web.Security.MembershipProvider.PasswordAttemptWindow' does not have an overridable set accessor C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 89 13 EmptyMVC 
Error 5 'EmptyMVC.Controllers.ProfileProvider.MinRequiredPasswordLength.set': cannot override because 'System.Web.Security.MembershipProvider.MinRequiredPasswordLength' does not have an overridable set accessor C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 56 13 EmptyMVC 
Error 4 'EmptyMVC.Controllers.ProfileProvider.MinRequiredNonAlphanumericCharacters.set': cannot override because 'System.Web.Security.MembershipProvider.MinRequiredNonAlphanumericCharacters' does not have an overridable set accessor C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 45 13 EmptyMVC 
Error 9 'EmptyMVC.Controllers.ProfileProvider.MaxInvalidPasswordAttempts.set': cannot override because 'System.Web.Security.MembershipProvider.MaxInvalidPasswordAttempts' does not have an overridable set accessor C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 100 13 EmptyMVC 
Error 12 'EmptyMVC.Controllers.ProfileProvider.EnablePasswordRetrieval.set': cannot override because 'System.Web.Security.MembershipProvider.EnablePasswordRetrieval' does not have an overridable set accessor C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 144 13 EmptyMVC 
Error 11 'EmptyMVC.Controllers.ProfileProvider.EnablePasswordReset.set': cannot override because 'System.Web.Security.MembershipProvider.EnablePasswordReset' does not have an overridable set accessor C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 133 13 EmptyMVC 
Error 1 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.PasswordStrengthRegularExpression.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
Error 2 'EmptyMVC.Controllers.ProfileProvider' does not implement inherited abstract member 'System.Web.Security.MembershipProvider.PasswordFormat.get' C:\Users\DigitalJedi\documents\visual studio 2010\Projects\EmptyMVC\EmptyMVC\Controllers\ProfileController.cs 12 18 EmptyMVC 
+0

속성에 '새'를 사용하는 이유를 설명 할 수 있습니까? 이것은 멤버를 적절히 오버라이드하는 방법이 아닙니다. – ChaosPandion

+3

모든 오류는 정확히 무엇이 잘못되었으며 어떻게 수정해야하는지 설명합니다. 너는 우리에게 뭐라 구요? –

+0

FYI - 귀하의 새로운 정보를 해결하기 위해 제 답변을 업데이트했지만, @EricLippert는 귀하가해야 할 일이 무엇인지 분명히해야합니다. – tvanfosson

답변

6

. new을 사용하면 기본 클래스에서 동일한 이름의 기존 메서드를 숨기지 만 해당 메서드를 실제로 구현하지 않는 새 메서드를 만듭니다. 메소드가 기본 클래스에서 abstract으로 선언되었으므로이를 추상화되지 않은 상속 클래스에서 구현해야합니다. override을 사용하면 new과 같이 기본 클래스에 정의 된 추상 메서드를 구현하는 대신 컴파일러에이를 알립니다.

: override을 사용할 때 나타나는 오류 메시지는 MembershipProvider가 해당 속성의 설정자를 구현하지 않았기 때문입니다. 이러한 속성에 대한 설정자를 제거하면 컴파일러 오류가 사라집니다. 공급자를 만들거나 구성 할 때 해당 속성의 백킹 필드를 설정하려는 경우가 많습니다.

생성 된 컴파일러 오류가 모호하거나 알려지지 않는 것으로 밝혀지지 않았습니다. 무슨 일이 일어나는지 분명해야합니다. 구현하고있는 클래스의 문서를 살펴 보는 것만으로 오류가있는 속성의 설정자가 없음을 알 수 있습니다.

+0

아, 사과 - 나는 그것을 시도했다고 언급하는 것을 잊었습니다. 나는 그 오류로도 편집 할 것입니다. – DigitalJedi805

+3

사실, 나는 그 오류가 아마도 유일한 문제라고 생각합니다. –

+0

@ DigitalJedi805 - 대신 다른 질문으로 제안하는 것이 좋습니다. 이제이 질문을 변경하면이 답변 (및 기타 답변)이 무효화됩니다. 새로운 질문이 더 적절할 것 같습니다. – tvanfosson

관련 문제