Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a wrapper for a C# library in Python
    primarykey
    data
    text
    <p>Main goal: Create a wrapper for a C# library, which can be used in Python (2.6).</p> <p>UPDATE: Now, I have updates to the method I am using, which is however not working well. </p> <p>The code for the simple C# class library:</p> <pre><code>using System; using System.Text; using System.Runtime.InteropServices; namespace Test { [Guid("8F38030D-52FA-4816-B587-A925FDD33302")] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface _TestClass { [DispId(1)] string Eureka(); } [Guid("BC3F6BB3-42C4-4F30-869A-92EA45BF68D2")] [ClassInterface(ClassInterfaceType.None)] [ProgId("Test.TestClass")] public class TestClass : _TestClass { public TestClass() { } public string Eureka() { return "Hudson, we no longer have a problem!"; } } } enter code here </code></pre> <p>In addition to this, I went into Project Properties and enabled the setting: Register for COM interop.</p> <p>Also, in order to make the class library available to COM, I ticked Signing -> Sign the Assembly, and gave it a strong key. </p> <p>Furthermore, whenever I compile, I unregister the old version with:</p> <pre><code>regasm -u Test /tlb:Test </code></pre> <p>And I register it with:</p> <blockquote> <p>regasm Test.dll /tlb:Test</p> </blockquote> <p>My problem is then, in the Python environment, I have the following main.py, which is not working:</p> <pre><code>import win32com.client o = win32com.client.Dispatch("Test.TestClass") </code></pre> <p>The error is unforgiven.</p> <p>thank you in advance!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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