Microsoft KB Archive/189065

= PRB: Catastrophic Failure Error Using an ActiveX Control =

Article ID: 189065

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Java Virtual Machine
 * Microsoft Software Development Kit for Java 2.02
 * Microsoft Software Development Kit for Java 2.01
 * Microsoft Software Development Kit for Java 2.02
 * Microsoft Software Development Kit for Java 3.0
 * Microsoft Software Development Kit for Java 3.1
 * Microsoft Software Development Kit for Java 3.2
 * Microsoft Visual J++ 1.0 Standard Edition
 * Microsoft Visual J++ 1.1 Standard Edition

-



This article was previously published under Q189065



SYMPTOMS
When trying to use a Visual C++ generated ActiveX Control from Java, you will see the following error when trying to run the Java application:

Error: Catastrophic failure Press any key to continue...



RESOLUTION
When trying to use an ActiveX Control as an automation server, you need to override the method IsInvokeAllowed. For more information on why this method has to be overridden, please see the REFERENCES section below.

To fix the problem, override IsInvokeAllowed in your ActiveX Control as follows: BOOL CMyOleControl::IsInvokeAllowed (DISPID) {

// You can check to see if COleControl::m_bInitialized is FALSE // in your automation functions to limit access. return TRUE; } For the example case given below, you will override this method in the Circ3ctl.cpp file and declare this virtual function in the Cir3ctl.h file. Also make sure you rebuild and re-register the control before using it from Java.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Build and register the Circ3.ocx sample that comes with Visual C++. Run JACTIVEX /javatlb circ3.ocx. This will create a folder called circ3 under %windir%\java\trustlib, which will contain .java files for the corresponding coclass, interfaces for the CIRC3.OCX.  Create a Java application as follows and import the ActiveX Control: import com.ms.com.*; import circ3.*;

public class circle {  public static void main(String args[]) {     circle main = new circle; main.test; } }

public void test {  _DCirc3 c  = null; c = (_DCirc3) new Circ3; c.AboutBox; }

}                        Build the Java application using the JVC that ships with the SDK for Java 2.0x or later. For more information on how to use this JVC with Visual J++, please see the REFERENCES section below. You will see the above mentioned error message.</ol>

<div class="references_section">