Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 晦涩';不实施';编译错误_C#_Model View Controller - Fatal编程技术网

C# 晦涩';不实施';编译错误

C# 晦涩';不实施';编译错误,c#,model-view-controller,C#,Model View Controller,我现在正在编写我的第一个MVC应用程序,正在创建一个新的会员资格提供商,但在这个过程中遇到了一些编译错误,这些错误完全是错误的。这是我的密码: public class ProfileProvider : MembershipProvider { protected NameValueCollection Config = null; protected new String Name = null; protected String _P

我现在正在编写我的第一个MVC应用程序,正在创建一个新的会员资格提供商,但在这个过程中遇到了一些编译错误,这些错误完全是错误的。这是我的密码:

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
这些错误对我来说是有意义的;比如“嘿,笨蛋,你需要这些东西”,但事实是我确实添加了这些东西。任何想法都很感激。提前谢谢

::编辑:::

忘了提到我曾尝试用“覆盖”替换“新”,结果在一艘类似的船上。以下是我在更改时的错误:

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

您应该在方法上使用
override
而不是
new
。当您使用
new
时,它会创建一个新方法,隐藏基类中同名的现有方法,但实际上并不实现该方法。由于该方法在基类中声明为
abstract
,因此需要在任何非抽象继承类中实现它。使用
override
通知编译器您正在实现基类中定义的抽象方法,而不是像
new
那样替换它

编辑:使用
覆盖
时收到的错误消息是因为MembershipProvider没有在这些属性上实现设置程序。删除这些属性的设置程序,编译器错误就会消失。在创建或配置提供程序时,可能需要为这些属性设置支持字段


我没有发现生成的编译器错误是模糊的或没有信息的。发生的事情应该是显而易见的。您所需要做的就是查看您正在实现的类的文档,您可以看到没有任何属性设置程序有错误。

啊,对不起,我忘了提到我尝试过了。我也会编辑这些错误。事实上,我认为这些错误可能是唯一重要的。@digitaljedic805-我建议换个问题问。现在更改此问题将使此答案(可能还有其他答案)无效。一个新的问题似乎更合适。这也是我的假设,只是我忘了意识到我忘了将其切换回去。@digitaljed805-我刚刚注意到您的类名为ProfileProvider,但实现了MembershipProvider。您知道您的类名与类的用途以及现有的ProfileProvider framework类冲突。您能解释一下为什么在属性上使用
new
?这不是您正确地覆盖成员的方式。所有这些错误都准确地描述了错误所在以及如何修复错误。你到底在问我们什么?仅供参考-我更新了我的答案,以解决你的新信息,但很明显你需要按照@EricLippert所说的做什么。