This sample is located in \Samples\Com\CCIEx.
Note It is recommended that you have Microsoft® Visual C++® version 5.0 or higher installed.
Description
Using the Sample
Key Project Files
Technologies Demonstrated
The CoCreateInstanceEx (CCIEx) sample uses a Java-implemented COM object through a custom interface to pass a string, array, and the client as a COM object. The interfaces are defined in IDL (Interface Definition Language), and used by the client and the server through the Java wrappers generated by jactivex. A Microsoft® J/Direct call to CoCreateInstanceEx creates instances of the in-process COM object, forms a local server, and forms a remote client.
To compile the remote client
Edit \Samples\Com\CCIEx\Sample\Dcom\RemoteClient.java as follows:
public final String serverName = null;
to the following:
public final String serverName=<this machine name>;
public final String userName = null;
to the following:
public final String userName=<the login name for the user that will be identified for security>;
public final String domainName = null;
to the following:
public final String domainName=<domain that the user is from>;
public final String password = null;
to the following:
public final String password=<password for the user on the specified domain>;
Nmake
To install the server sample
In \Samples\Com\CCIEx, run Register.bat.
This displays two dialog boxes indicating that the COM object and the proxy/stub were registered correctly.
To install the client sample
In \Samples\Com\CCIEx, run Clientreg.bat.
This displays a message stating that the proxy/stub was registered correctly.
To uninstall the server sample
In \Samples\Com\CCIEx, run Remove.bat.
This displays two messages stating that the COM object and the proxy/stub were removed correctly.
To uninstall the client sample
In \Samples\Com\CCIEx, run Clientrem.bat.
This displays a message stating that the proxy/stub was removed correctly.
To run the inproc sample
From \Samples\Com\CCIEx, run the following command:
jview sample.dcom.InprocClient
If successful, this displays the output from the COM object and the Client. The last message will be InprocClient - Done.
To run the local server sample
From \Samples\Com\CCIEx, run the following command:
jview sample.dcom.OutprocClient
If successful, this displays the output from the COM object and the Client. The last message will be OutprocClient - Done.
Note The local server case may fail with an RPC error (HRESULT = 800706BE).
This is because in Microsoft® Windows NT®, version 4, the main thread of Dllhost.exe waits for COM to tell it to shut down. COM signals a shutdown whenever the total proxy count in the process is 0 (zero). The Microsoft virtual machine cocreates an MDM process to ask if the object should be debugged and then immediately released. That triggers the proxy count to reach 0 (zero) and the process goes away in the middle of an otherwise successful run.
You can avoid the debug check by removing the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Java VM\MSDEBUG registry key that is automatically added by Visual J++. Note that VJ will continue to add this key each time VJ is run.
Changing the threading model for the Hub2 Java/COM object in the registry to ThreadingModel=Apartment makes this work, probably because you end up with a proxy out of an STA COM worker thread to one of the surrogate's MTA worker threads. With ThreadingModel=Both, you end up directly on the MTA worker thread and don't create a proxy.
To run the remote client sample from the remote machine
From \Samples\Com\CCIEx, run the following command:
jview sample.dcom.RemoteClient
If successful, this displays the output from the COM object and the Client. The last message will be RemoteClient - Done.
This batch file contains the client registration information for adding the Proxystub.dll file into the local registry. This is required for marshaling the custom interface on the Java/COM object.
clientrem.batThis batch file removes the Proxystub.dll file from the registry of the client registry.
register.batThis batch file registers the Java/COM object and Proxystub.dll.
Hub2.javaThis class contains the implementation of the Java/COM object.
InprocClient.javaThis class contains the implementation of the in-process client.
OutprocClient.javaThis class contains the implementation of the local-server client.
RemoteClient.javaThis class contains the implementation of a remote client.
This sample shows how to: