Python.net and DLLs
Question: I want to call a .Net dll using Python.net. Essentially what I want to do is
operate a hardware device that comes with some dlls and sample C# code for
operating it.

The sample of C# code I want to reimplement in python is:

    
    
        string[] strDeviceKeys = null;
        CmdLib8742 cmdLib = new CmdLib8742 (true, 5000, ref strDeviceKeys);
    

CmdLib8742 comes from a .net dll.

python.net _seems_ to be installed correctly.

I can do this in python:

    
    
    import clr
    clr.AddReference('CmdLib')
    import NewFocus.Picomotor
    cl = NewFocus.Picomotor.CmdLib8742()
    

That runs without error, but obviously doesn't seem to actually connect to the
device.

It seems like I need to convert the python types to types that are understood
by C#, so I probably have to replace `true` with `System.Boolean(True)`. But
it's not clear to me how I pass this `ref strDeviceKeys`. I'm guessing this is
passing a reference to the array of strings, but I don't know how to do that
in python. Any help would be appreciated.

Thanks.


Answer: You will probably need to look at [the `ctypes`
library](https://docs.python.org/3.5/library/ctypes.html), which allows
conversion between architecture-specific and Python values.

