Python Forum
Using C++/CLI wrapper functions by Python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Using C++/CLI wrapper functions by Python (/thread-36525.html)



Using C++/CLI wrapper functions by Python - Ales1000 - Mar-01-2022

Hello,

I have created C++ Dll to be loaded by many programs, interfaces (also Python). This Dll is calling another C++/CLI Dll wrapper which wraps C# Dll (Licencing functions).

This program can work in several interfaces fine (C++ .exe, C# GUI...), but when calling by Python it fails always on the C++/CLI Dll wrapper function. In this, it is also unable to go inside the C++/CLI Dll function (probably unable to load the Dll). When I call it from Python console, I receive

Traceback (most recent call last): File "", line 1, in OSError: [WinError -532462766] Windows Error 0xe0434352

I found out on internet that this is reported by many authors. But I was not able to find any solution.

I really don't understand why is that? As I mentioned, I call Dll also from C++ .exe or C# .exe without any problem. Also if I comment wrapper function, then can use all C++ Dll functions without errror.

Thank you in advance for your answer.


RE: Using C++/CLI wrapper functions by Python - Benji130 - Jun-20-2022

Hello,

I have an issue similar to the one you describe, raising the same error. I developed a DLL in C++ that, for a specific case, call a function of a second (external) DLL. It works fine in C++ but it fails for this specific case when it is called from Python code.
Following this thread, https://stackoverflow.com/questions/45799310/embed-pcap-dll-files-into-c-sharp-project-created-dll, I have found that if I put my external DLL where my python.exe is it works fine.

I then tried to specify the path to my external DLL using the function os.add_dll_directory() but it seems to be useless.

Since you asked your question 3 months ago, I was wondering if you found a way to overcome your issue?

Thanks


RE: Using C++/CLI wrapper functions by Python - Ales1000 - Jun-21-2022

Hello,

I am really suprised. I found out that this forum is dead.

The problem was as you described. It is assumed that dependencies are nearby .exe (Python). Here is the solution

http://pragmateek.com/if-your-plumbing-doesnt-work-youre-just-not-using-enough-pipes/#more-1745

Hope this help you as me.