0

I'm trying to call from python code C# functions from a dll using Python for .NET. Most things worked out of the box or I could figure them out from other posts, but the last thing that refuses to work is to pass a byte[] as a parameter.

Here's the C# function

    NCICoreConnCreateCmd (
        DestinationType type,           // enumeration
        DestinationParameter parameter, // enumeration
        byte[] val
        )

Here's the python code

    import COOT.Protocol.NCI.ControlMessage
    import COOT.Protocol.NCI.ControlMessage.Core

    # from System.Collections.Generic import List
    import System.Collections.Generic as C

    from System import Byte
    from System import Array

    t = COOT.Protocol.NCI.ControlMessage.DestinationType.NFCEE
    par = COOT.Protocol.NCI.ControlMessage.DestinationParameter.RFDiscoveryIdAndProtocol
    val = Array[Byte]([Byte(0), Byte(0)])
    cmd = COOT.Protocol.NCI.ControlMessage.Core.NCICoreConnCreateCmd(t, par, val)

And the error message,

TypeError: No constructor matches given arguments: (<class 'int'>, <class 'int'>, <class 'System.Byte[]'>)

Besides this issue, what about the method below? A more complicate 'List<(DestinationParameter parameter, byte[] val)> list' parameter in the road.

NCICoreConnCreateCmd( DestinationType  type, List<(DestinationParameter parameter, byte[] val)>  list) 

Any suggestion will be appreciate, thank you in advance.

ATR
  • 36
  • 5

0 Answers0