Note that there are some explanatory texts on larger screens.

plurals
  1. POPython ctypes and DLL that uses a COM object
    primarykey
    data
    text
    <p>Under Windows, I'm trying to use a 3rd party DLL (<code>SomeLib.dll</code>) programmed in C++ from Python 2.7 using <code>ctypes</code>. For some of its features, this library uses another COM DLL (<code>SomeCOMlib.dll</code>), which itself uses other DLL (<code>LibA.dll</code>).</p> <p><em>Please note that this isn't about using a COM DLL directly from Python, but it's about using a DLL that uses it from Python.</em></p> <p>To make the integration with Python easier, I've grouped the calls I want to use into my own functions in a new DLL (<code>MyLib.dll</code>), also programmed in C++, simply to make the calls from <code>ctypes</code> more convenient (using <code>extern "C"</code> and tailoring the functions for specific scenarios). Essentially, my library exposes 2 functions: <code>doSomethingSimple()</code>, <code>doSomethingWithCOMobj()</code> (all returning <code>void</code>, no parameters).</p> <p>The "effective" dependency hierarchy is as follows:</p> <pre class="lang-none prettyprint-override"><code>MyLib.dll SomeLib.dll SomeCOMlib.dll LibA.dll </code></pre> <p>I'm able to write a simple C++ console application (Visual C++) that uses <code>MyLib.dll</code> and makes those 2 consecutive calls without problem.</p> <p>Using Python/ctypes, the first call works fine, but the call that makes use of COM throws a <code>WindowsError: [Error -529697949] Windows Error 0xE06D7363</code>. From the rest of the library behaviour, I can see that the problem comes exactly where that COM call is made.</p> <p>(The simple test C++ application also fails more or less at the same place if <code>LibA.dll</code> is missing, but I'm not sure if it's related.)</p> <p>I've looked at the dependency hierarchy using <a href="http://www.dependencywalker.com/" rel="noreferrer">Dependency Walker</a>. <code>SomeCOMlib.dll</code> isn't listed as a dependency of <code>SomeLib.dll</code>, although it's clearly required, and <code>LibA.dll</code> isn't listed as a dependency of <code>SomeCOMlib.dll</code>, although it's also clearly required at run time.</p> <p>I'm running everything from the command line, from within the directory where these DLLs are (and the C++ sample executable works fine). I've tried to force the PATH to include that directory, and I've also tried to copy the DLLs to various places where I guessed they might be picked up (<code>C:\Windows\System32</code> and <code>C:\Python27\DLLs</code>), without success. <code>SomeCOMlib.dll</code> was also registered with <code>regasm.exe</code>.</p> <p><strong>What could cause this difference between using this DLL from a plain C++ application and from Python's <code>ctypes</code> when it comes to its own usage of the COM mechanism (and possibly the subsequent loading of other DLLs there)?</strong></p> <p><strong>Which steps would give at least a bit more information than <code>Windows Error 0xE06D7363</code> from Python, to be able to investigate the problem further?</strong></p> <p>The Python code looks like this:</p> <pre class="lang-python prettyprint-override"><code>import ctypes myDll = ctypes.WinDLL("MyLib.dll") myDll.doSomethingSimple() myDll.doSomethingWithCOMobj() # This statement throws the Windows Error </code></pre> <p>(The test C++ standalone application that works, linked to <code>MyLib.dll</code> makes exactly the same calls within <code>main</code>.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload