AxHost.InvalidActiveXStateException AxHost.InvalidActiveXStateException AxHost.InvalidActiveXStateException AxHost.InvalidActiveXStateException Class

定义

引用处于无效状态的 ActiveX 控件时引发的异常。The exception that is thrown when the ActiveX control is referenced while in an invalid state.

public: ref class AxHost::InvalidActiveXStateException : Exception
public class AxHost.InvalidActiveXStateException : Exception
type AxHost.InvalidActiveXStateException = class
    inherit Exception
Public Class AxHost.InvalidActiveXStateException
Inherits Exception
继承
AxHost.InvalidActiveXStateExceptionAxHost.InvalidActiveXStateExceptionAxHost.InvalidActiveXStateExceptionAxHost.InvalidActiveXStateException

示例

下面的代码示例重写构造函数中,并SetAboutBoxDelegateAttachInterfaces方法的AxHost派生的类包装 Microsoft 屏蔽编辑 ActiveX 控件。The following code example overrides the constructor, and the SetAboutBoxDelegate and AttachInterfaces methods of an AxHost derived class that wraps the Microsoft Masked Edit ActiveX Control. 此代码需要通过运行 AxImp.exe MSMask32.ocx 文件上创建了生成的源代码/source开关来生成包装器类,以便对其进行编辑。This code requires that you have created the generated source code by running the AxImp.exe on the MSMask32.ocx file with the /source switch to generate the wrapper class to be edited. 此代码仅显示 C# 语法因为这是唯一的语言输出由 AxImp.exe。This code is only shown in C# syntax because that is the only language output by the AxImp.exe.

public AxMaskEdBox()
    :
  base("c932ba85-4374-101b-a56c-00aa003668dc") // The ActiveX control's class identifier.
{
    // Make the AboutBox method the about box delegate.
    this.SetAboutBoxDelegate(new AboutBoxDelegate(AboutBox));
}

public virtual void AboutBox()
{
    // If the instance of the ActiveX control is null when the AboutBox method 
    // is called, raise an InvalidActiveXStateException exception.
    if ((this.ocx == null))
    {
        throw new System.Windows.Forms.AxHost.InvalidActiveXStateException(
          "AboutBox", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke);
    }
    // Show the about box if the ActiveX control has one.
    if (this.HasAboutBox)
    {
        this.ocx.AboutBox();
    }
}

protected override void AttachInterfaces()
{
    try
    {
        // Attach the IMSMask interface to the ActiveX control.
        this.ocx = ((MSMask.IMSMask)(this.GetOcx()));
    }
    catch (System.Exception ex)
    {
        System.Console.WriteLine(ex.Message);
    }
}

注解

公共属性和 ActiveX 控件的方法仅可引用后实例化 ActiveX 控件并将其完全; 初始化否则为AxHost.InvalidActiveXStateException引发异常。The public properties and methods of an ActiveX control can only be referenced after the ActiveX control has been instantiated and initialized completely; otherwise the AxHost.InvalidActiveXStateException exception is thrown. AxHost.InvalidActiveXStateException异常类包含进行引用的成员和成员类型的名称。The AxHost.InvalidActiveXStateException exception class contains the name of the member that made the reference and the member type. 成员类型是之一AxHost.ActiveXInvokeKind枚举值。The member type is one of the AxHost.ActiveXInvokeKind enumerated values.

构造函数

AxHost.InvalidActiveXStateException() AxHost.InvalidActiveXStateException() AxHost.InvalidActiveXStateException() AxHost.InvalidActiveXStateException()

初始化 AxHost.InvalidActiveXStateException 类的新实例,但不指定有关引用了该 ActiveX 控件的成员的信息。Initializes a new instance of the AxHost.InvalidActiveXStateException class without specifying information about the member that referenced the ActiveX control.

AxHost.InvalidActiveXStateException(String, AxHost+ActiveXInvokeKind) AxHost.InvalidActiveXStateException(String, AxHost+ActiveXInvokeKind) AxHost.InvalidActiveXStateException(String, AxHost+ActiveXInvokeKind) AxHost.InvalidActiveXStateException(String, AxHost+ActiveXInvokeKind)

初始化 AxHost.InvalidActiveXStateException 类的新实例,并指示引用了该 ActiveX 控件的成员的名称及所进行的引用的种类。Initializes a new instance of the AxHost.InvalidActiveXStateException class and indicates the name of the member that referenced the ActiveX control and the kind of reference it made.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetBaseException() GetBaseException() GetBaseException() GetBaseException()

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

(Inherited from Exception)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

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

(Inherited from Exception)
GetType() GetType() GetType() GetType()

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

(Inherited from Exception)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
ToString() ToString() ToString() ToString()

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

属性

Data Data Data Data

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

(Inherited from Exception)
HelpLink HelpLink HelpLink HelpLink

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

(Inherited from Exception)
HResult HResult HResult HResult

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

(Inherited from Exception)
InnerException InnerException InnerException InnerException

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

(Inherited from Exception)
Message Message Message Message

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

(Inherited from Exception)
Source Source Source Source

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

(Inherited from Exception)
StackTrace StackTrace StackTrace StackTrace

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

(Inherited from Exception)
TargetSite TargetSite TargetSite TargetSite

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

(Inherited from Exception)

事件

SerializeObjectState SerializeObjectState SerializeObjectState SerializeObjectState

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

(Inherited from Exception)

适用于

另请参阅