AxHost.InvalidActiveXStateException (Clase)
Actualización: noviembre 2007
Excepción que se produce cuando se hace referencia al control ActiveX mientras se encuentra en un estado no válido.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")] [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")] public class InvalidActiveXStateException : Exception
/** @attribute PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust") */ /** @attribute PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust") */ public class InvalidActiveXStateException extends Exception
Sólo se puede hacer referencia a las propiedades y métodos públicos de un control ActiveX tras crear una instancia e inicializar completamente dicho control; de lo contrario, se produce la excepción AxHost.InvalidActiveXStateException. La clase de excepción AxHost.InvalidActiveXStateException contiene el nombre del miembro que hace la referencia y el tipo de miembro. El tipo de miembro es uno de los valores enumerados de AxHost.ActiveXInvokeKind.
En el siguiente ejemplo de código se reemplaza el constructor, así como los métodos SetAboutBoxDelegate y AttachInterfaces de una clase derivada AxHost que contiene el control ActiveX Masked Edit de Microsoft. En este código se requiere que se haya creado el código fuente generado ejecutando AxImp.exe en el archivo MSMask32.ocx con el modificador /source para generar la clase contenedora que se va a editar. Este código se muestra únicamente en sintaxis de C# ya que es el único lenguaje de Axlmp.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); } }
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.