Antti Nivala
2006-11-01 20:05:41 UTC
I have encountered a problem in using Autodesk's DWG IFilter on Windows XP.
This IFilter gets installed with AutoCAD 2006 and newer as well as with
AutoCAD LT 2006 and newer.
Calling LoadIFilter for a DWG file succeeds on Windows 2000 in my test
application (both in an STA thread and in an MTA thread, using C++).
The problem:
The same LoadIFilter call for a DWG file fails on Windows XP if COM has been
initialized to MTA in the calling thread. The error code is 0x80004002 (No
such interface supported). The call succeeds if I initialize COM to STA in
the calling thread.
I can get the LoadIFilter call to succeed in an MTA thread if I change the
DWG IFilter component's threading model from Apartment to Both in the
registry.
So clearly this is a COM threading related issue. Additionally, it is
somehow also related to some difference between Windows 2000 and XP because
the problem does not occur on Windows 2000 systems. Anyway, what I am
interested in is how to get this to work on Windows XP without making the
changes to registry.
I guess that I can solve the problem if I can change our application so that
it always uses IFilters from an STA thread. But before going that way, I
would like to understand why I would have to do that. Shouldn't COM let me
use the IFilter component from an MTA thread? Since this is not working in
practice in this case, where is the actual problem? Is Autodesk's DWG
IFilter component faulty in this respect? Or am I doing something wrong in
my very simple LoadIFilter call? Or is there an architectural reason why an
IFilter whose threading model is Apartment cannot be invoked from an MTA
thread?
If I call LoadIFilter from an STA thread, will that work for all IFilters?
Or can there be some IFilter components out there that require MTA instead?
Please direct me to the correct newsgroup if this is a wrong one.
Antti
This IFilter gets installed with AutoCAD 2006 and newer as well as with
AutoCAD LT 2006 and newer.
Calling LoadIFilter for a DWG file succeeds on Windows 2000 in my test
application (both in an STA thread and in an MTA thread, using C++).
The problem:
The same LoadIFilter call for a DWG file fails on Windows XP if COM has been
initialized to MTA in the calling thread. The error code is 0x80004002 (No
such interface supported). The call succeeds if I initialize COM to STA in
the calling thread.
I can get the LoadIFilter call to succeed in an MTA thread if I change the
DWG IFilter component's threading model from Apartment to Both in the
registry.
So clearly this is a COM threading related issue. Additionally, it is
somehow also related to some difference between Windows 2000 and XP because
the problem does not occur on Windows 2000 systems. Anyway, what I am
interested in is how to get this to work on Windows XP without making the
changes to registry.
I guess that I can solve the problem if I can change our application so that
it always uses IFilters from an STA thread. But before going that way, I
would like to understand why I would have to do that. Shouldn't COM let me
use the IFilter component from an MTA thread? Since this is not working in
practice in this case, where is the actual problem? Is Autodesk's DWG
IFilter component faulty in this respect? Or am I doing something wrong in
my very simple LoadIFilter call? Or is there an architectural reason why an
IFilter whose threading model is Apartment cannot be invoked from an MTA
thread?
If I call LoadIFilter from an STA thread, will that work for all IFilters?
Or can there be some IFilter components out there that require MTA instead?
Please direct me to the correct newsgroup if this is a wrong one.
Antti