|
From: Castro, E. M. (PCA) <EC...@NA...> - 2000-12-08 15:39:14
|
Since we have done something like this let me understand your situation.
1.- After the CoCreateInstance of your C++ DLL, does the CAD application
call any method passing a reference to a reference to itself or do you call
CoCreateInstance on the Application component?
2.- Do you know if the CAD Application COM component is free-threaded?
The reason I ask is because you may have to marshal interface pointers to
be usable from a thread other than the main thread.
(CoMarshalInterThreadInterfaceInStream, etc)
3.- What do you mean for crash? what is the exact error?
Access violations, etc?
4.- What OS, java VM?
5.- What exactly are you trying to do when the crash happens? Can you debug
it?
6.- Is all interfacing beetween the third party application a COM-based
interface?.
If it is I am sorry to suggest the following and the intent is not to create
one of the many religious war (my **ck is better than yours). Wouldn't have
been easier to use the Microsoft Java SDK to create a Java COM component
without the use of any C++ code in between. We have done the same for some
third party apps.
-----Original Message-----
From: niceguy [mailto:ni...@ab...]
Sent: Friday, December 08, 2000 9:11 AM
To: min...@li...
Subject: [Mingw-users] Mingw, COM, JNI, MFC and threads
Yes, I am trying to combine all the items in the subject in a single
project. :)
I've bumped into a very specific problem, which may or may not be Mingw
related, and I'd like to bounce it off of the various experienced Mingw
users here in hopes of finding a solution. I'm a programmer by hobby, not
by trade, so the more specific the advice the better.
Some background:
I have a third party application developed with MFC. Specifically it is a
CAD application for mechanical design (my actual profession). This
application exposes portions of its API via COM. My primary area of
programming experience is Java, so I have been working on porting the entire
CAD application COM API to a more OO, simpler, Java API using JNI to act as
a bridge from Java to COM.
To use the COM interfaces, the CAD application requires that the code be
contained in a DLL which is then loaded into the CAD application's process,
in a fashion similar to Add-Ins for Word, Excel, etc. To meet this
restriction, I simply created a C++ DLL which adds some menu items ot the
CAD application. These menu items can be used to start the Java Virtual
Machine via JNI, and run various Java applications which can call back into
the COM API.
The current situation:
The API porting and add-in DLL issues are resolved, and I am left with the
task of testing my Java API for correctness and stability. Since I'm dealing
with 100 classes with several thousand methods in total, I went looking for
a testing tool that could automate some of this. There is a unit testing
package called JUnit which fits my needs quite nicely, providing a GUI to
run various tests and assess the output. It was a trivial task to have my
JNI DLL provide a menu item in the CAD application which could be used to
start the JUnit application.
The problem:
When I start the JUnit application and attempt to run tests, I get a
spectacular crash from the MS C++ runtime. After much fiddling and
debugging, I have determined that the crash only happens when a thread other
than the the main thread of the Java application makes a call to the COM
interface of the CAD application. If I start the JUnit program and pass in
the name of a test to run, the test completes successfully. If I select the
test from a list in the GUI and try to run it, the crash occurs, because the
code is running in the Java event dispatch thread. If I create a new thread
from inside the main thread and run tests, the crash occurs. So it is
definitely thread-related. This problem essentially means that no Java
application with a GUI can be used to interact with the CAD application,
which is a restriction I would rather not have, for obvious reasons.
The question:
Are there any specific issues related to COM and threads in the context of a
DLL compiled with Mingw? Is there anything special I should be doing when
compiling and/or linking?
Any/All assistance appreciated,
Jim S.
_______________________________________________
MinGW-users mailing list
Min...@li...
You may change your MinGW Account Options at:
http://lists.sourceforge.net/mailman/listinfo/mingw-users
|