IMessageFilter not triggering in custom DLLs

IMessageFilter not triggering in custom DLLs

Anonymous
Not applicable
871 Views
2 Replies
Message 1 of 3

IMessageFilter not triggering in custom DLLs

Anonymous
Not applicable

I'm trying to understand why IMessageFilter might not be working in my custom DLLs - I'm gettng all sorts of errors telling me that AutoCAD is busy.

 

Basically my setup is that I have a business application utility.  This utility calls our own custom DLL, at one point, in order to automate AutoCAD and read drawing information -- i.e. it contains methods for opening AutoCAD, and executing other AutoCAD related functions using COM.  The classes in the DLL Implement ImessageFilter (pretty much the method used here:  http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-b...

 

If AutCAD is not open, it opens it ---note that I haven't had the error problems if the target drawing is already open, probably because AutoCAD isn't running any threads at that point; also note that when it opens a drawing and/or AutoCAD, our AutoCAD has both lisp and .Net startup routines, so it's probably running a couple threads in addition to the native startup ones.

 

Basically my problem is that IMessageFilter does not appear to be triggering in the DLLs at all.  It may be possible that IMessageFilter is running in a couple tiers at times.

 

If anyone has seen this behavior and might know it's cause, any feedback is appreciated.

 

 

0 Likes
872 Views
2 Replies
Replies (2)
Message 2 of 3

FRFR1426
Collaborator
Collaborator

If your utility is a console app, it's running in a multithreaded apartment (MTA) and this kind of application cannot have message filters. You have to add the STAThread attribute on your Main method to tell the CLR to run your application in this kind of apartment. In the post of Kean, there is a comment about that : http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-b...

 

You can also read this : http://infosys.beckhoff.com/english.php?content=../content/1033/tc3_automationinterface/540431957711...

 

 

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 3 of 3

Anonymous
Not applicable

The app is not a console app.  My only thought is that there is a problem because all of the cad automation is happening through a DLL reference of our own making.  Because the CAD automation is in the DLL, so is the IMessageFilter code.

0 Likes