NotImplementedException Class


在请求的方法或操作未实现时引发的异常。The exception that is thrown when a requested method or operation is not implemented.

public ref class NotImplementedException : Exception
public ref class NotImplementedException : SystemException
public class NotImplementedException : Exception
public class NotImplementedException : SystemException
public class NotImplementedException : SystemException
public class NotImplementedException : SystemException
type NotImplementedException = class
    inherit Exception
type NotImplementedException = class
    inherit SystemException
Public Class NotImplementedException
Inherits Exception
Public Class NotImplementedException
Inherits SystemException


下面的示例为尚未开发的方法引发此异常。The following example throws this exception for a method that has not been developed.

static void Main(string[] args)
    catch (NotImplementedException notImp)

static void FutureFeature()
    // Not developed yet.
    throw new NotImplementedException();
Sub Main()
    Catch NotImp As NotImplementedException
    End Try

End Sub

Sub FutureFeature()
    ' not developed yet.
    Throw New NotImplementedException()
End Sub


当特定方法、get 访问器或 set 访问器作为类型的成员存在但未实现时,将引发 NotImplementedException 异常。The NotImplementedException exception is thrown when a particular method, get accessor, or set accessor is present as a member of a type but is not implemented.

NotImplementedException 使用默认的 Object.Equals 实现,该实现支持引用相等性。NotImplementedException uses the default Object.Equals implementation, which supports reference equality. 有关 NotImplementedException实例的初始值列表,请参见 NotImplementedException 构造函数。For a list of initial values for an instance of NotImplementedException, see the NotImplementedException constructors.

引发异常Throwing the exception

当该成员仍处于开发阶段并且稍后将在生产代码中实现时,你可以选择在自己的类型中的属性或方法中引发 NotImplementedException 异常。You might choose to throw a NotImplementedException exception in properties or methods in your own types when the that member is still in development and will only later be implemented in production code. 换句话说,NotImplementedException 异常应与 "仍在开发中" 同义词。In other words, a NotImplementedException exception should be synonymous with "still in development."

处理异常Handling the exception

NotImplementedException 异常指示您尝试调用的方法或属性没有实现,因此不提供任何功能。The NotImplementedException exception indicates that the method or property that you are attempting to invoke has no implementation and therefore provides no functionality. 因此,不应在 try/catch 块中处理此错误。As a result, you should not handle this error in a try/catch block. 相反,应该从代码中移除成员调用。Instead, you should remove the member invocation from your code. 在库的生产版本中实现成员时,可以包括对该成员的调用。You can include a call to the member when it is implemented in the production version of a library.

在某些情况下,不能使用 NotImplementedException 异常来指示仍在预生产库中开发的功能。In some cases, a NotImplementedException exception may not be used to indicate functionality that is still in development in a pre-production library. 但是,这仍表示功能不可用,您应该从代码中移除成员调用。However, this still indicates that the functionality is unavailable, and you should remove the member invocation from your code.

NotImplementedException 和其他异常类型NotImplementedException and other exception types

.NET Framework 还包括两个其他异常类型,NotSupportedExceptionPlatformNotSupportedException,指示类型的特定成员不存在实现。The .NET Framework also includes two other exception types, NotSupportedException and PlatformNotSupportedException, that indicate that no implementation exists for a particular member of a type. 在下列条件下,应引发其中一个而不是 NotImplementedException 异常。You should throw one of these instead of a NotImplementedException exception under the following conditions.

PlatformNotSupportedException 异常PlatformNotSupportedException exception
如果你使用一个或多个成员(在某些平台上或在某些版本中不可用)设计了类型,则可以在不支持该功能的平台上引发此异常。If you've designed a type with one or more members that are available on some platforms or in some versions but not on others, you can throw this exception on platforms on which the functionality is not supported.

NotSupportedException 异常NotSupportedException exception
如果接口成员的实现或抽象基类方法的重写不可能,则引发 NotSupportedException 异常。Throw a NotSupportedException exception if the implementation of an interface member or an override to an abstract base class method is not possible. 例如,Convert.ToInt32(DateTime) 方法引发 NotSupportedException 异常,因为日期和时间与32位有符号整数之间没有有意义的转换。For example, the Convert.ToInt32(DateTime) method throws a NotSupportedException exception because no meaningful conversion between a date and time and a 32-bit signed integer exists. 此方法中必须存在方法,因为 Convert 类实现 IConvertible 接口。The method must be present in this case because the Convert class implements the IConvertible interface.

如果已实现抽象基类并向其添加必须由派生类重写的新成员,还应引发 NotSupportedException 异常。You should also throw a NotSupportedException exception if you've implemented an abstract base class and add a new member to it that must be overridden by derived classes. 在这种情况下,使成员抽象使现有子类无法加载。In that case, making the member abstract causes existing subclasses to fail to load.



使用默认属性初始化 NotImplementedException 类的新实例。Initializes a new instance of the NotImplementedException class with default properties.

NotImplementedException(SerializationInfo, StreamingContext)

使用序列化数据初始化 NotImplementedException 类的新实例。Initializes a new instance of the NotImplementedException class with serialized data.


用指定的错误消息初始化 NotImplementedException 类的新实例。Initializes a new instance of the NotImplementedException class with a specified error message.

NotImplementedException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 NotImplementedException 类的新实例。Initializes a new instance of the NotImplementedException class with a specified error message and a reference to the inner exception that is the cause of this exception.



获取键/值对的集合,这些键/值对提供有关该异常的其他用户定义信息。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(Inherited from Exception)

获取或设置指向与此异常关联的帮助文件链接。Gets or sets a link to the help file associated with this exception.

(Inherited from Exception)

获取或设置 HRESULT(一个分配给特定异常的编码数字值)。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(Inherited from Exception)

获取导致当前异常的 Exception 实例。Gets the Exception instance that caused the current exception.

(Inherited from Exception)

获取描述当前异常的消息。Gets a message that describes the current exception.

(Inherited from Exception)

获取或设置导致错误的应用程序或对象的名称。Gets or sets the name of the application or the object that causes the error.

(Inherited from Exception)

获取调用堆栈上的即时框架字符串表示形式。Gets a string representation of the immediate frames on the call stack.

(Inherited from Exception)

获取引发当前异常的方法。Gets the method that throws the current exception.

(Inherited from Exception)



确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)

当在派生类中重写时,返回 Exception,它是一个或多个并发的异常的根本原因。When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(Inherited from Exception)

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext)

当在派生类中重写时,用关于异常的信息设置 SerializationInfoWhen overridden in a derived class, sets the SerializationInfo with information about the exception.

(Inherited from Exception)

获取当前实例的运行时类型。Gets the runtime type of the current instance.

(Inherited from Exception)

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)

创建并返回当前异常的字符串表示形式。Creates and returns a string representation of the current exception.

(Inherited from Exception)



当异常被序列化用来创建包含有关该异常的徐列出数据的异常状态对象时会出现该问题。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(Inherited from Exception)

Applies to

See also