Discussion:
[OLE] Controlling AutoCAD >= 2010 fails with Win32::OLE. Error 0x8001010a.
Manuel Reimer
2011-03-03 09:55:04 UTC
Permalink
Hello,

we use Perl and the Win32::OLE module to do some automatic drawing
modifications with AutoCAD. Several scripts have been created and they
work well with AutoCAD up to 2009.

Starting with AutoCAD 2010 it unfortunately gets nearly impossible to
get a stable communication between Perl and AutoCAD with Win32::OLE. I
get errors like the following one:

| Win32::OLE(0.1709) error 0x8001010a: "Durch den Messagefilter wurde
| angezeigt, dass die Anwendung ausgelastet ist"
| in METHOD/PROPERTYGET "" at C:\bin\test.pl line 20

Searching the net revealed, that such errors also occur with Excel,
sometimes, but no solution.

I tried several things like catching the error from Perl to retry the
call and even tried to implement some retry code in the OLE.xs file
until I found the following from Autodesk:

<http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-by-autocad-from-an-external-net-application.html>

This C# and so I tried to port this over to C++ to be able to add this
to the OLE.xs file. I've attached the patch file with my proof of
concept code.

As you see in my patch, I commented out the code, initializing OLE in
multi threading mode, to make the CoRegisterMessageFilter call succeed.

Problem with this patch: It doesn't work. Anything, it does, is crashing
the Perl interpreter... :-(

Is someone here able to have a look at this and perhaps fix this code?

Thank you very much in advance.

Mit freundlichen Grüßen / Best regards

Manuel Reimer


Bosch Rexroth. The Drive & Control Company

Tel. 09352/18-1578

***@boschrexroth.de
www.boschrexroth.com

Bosch Rexroth AG
Maria-Theresien-Straße 23
97816 Lohr am Main
GERMANY

Firmensitz: Stuttgart, Registrierung: Amtsgericht Stuttgart HRB 23192
Vorstand: Dr. Karl Tragl (Vorsitzender), Dr. Georg Hanen; Reiner
Leipold-Büttner; Dr. Stefan Spindler
Vorsitzender des Aufsichtsrats: Dr. Siegfried Dais
Jan Dubois
2011-03-07 19:46:50 UTC
Permalink
On Thu, 03 Mar 2011, Manuel Reimer wrote:

Hi Manuel,

[...]
Post by Manuel Reimer
<http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-
by-autocad-from-an-external-net-application.html>
This C# and so I tried to port this over to C++ to be able to add this
to the OLE.xs file. I've attached the patch file with my proof of
concept code.
As you see in my patch, I commented out the code, initializing OLE in
multi threading mode, to make the CoRegisterMessageFilter call succeed.
The way to tell Win32::OLE to use OleInitialize() is to call

Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE());

right after you "use" Win32::OLE. Put it inside a BEGIN block if you
may call any OLE functionality at compile time (e.g. while loading other
code).
Post by Manuel Reimer
Problem with this patch: It doesn't work. Anything, it does, is crashing
the Perl interpreter... :-(
It is not crashing for me just running the bundled test suite. Do you have
some sample script that crashes that doesn't involve AutoCAD, as I don't
have a copy of that application available.
Post by Manuel Reimer
Is someone here able to have a look at this and perhaps fix this code?
I haven't really looked at your code; just applied the patch, built the
module and ran the tests, with no crash in sight.

So I assume the crash only happens when the MessageFilter is actually
being invoked. I'll try to look at your implementation to see if I can
find anything that could go wrong, but having a reproducible crash would
make this easier.

Cheers,
-Jan

Loading...