TypeError calling .NET method using Pythonnet

598 views Asked by At

I'm having a problem calling a method from a .NET dll linked to the eBUS SDK. The end goal of the code is to communicated to a GigE connected camera using python.

In C#, the method is: public void SetStreamDestination( string aIPAddress, ushort aDataPort ) , and is part of a class called PvDeviceGEV.

In Python, I'm using pythonnet to import the dll. I'm then using this code:

from PvDotNet import PvDeviceGEV
from PvDotNet import PvStreamGEV

DeviceGEV = PvDeviceGEV()
Stream = PvStreamGEV()

LocalIP = Stream.LocalIPAddress
LocalPort = Stream.LocalPort
DeviceGEV.SetStreamDestination(LocalIP, LocalPort)

This results in an error:

TypeError: No method matches given arguments for SetStreamDestination: (<class 'str'>, <class 'int>)

Seeing as the types of IPAddress and aDataPort should be string and UInt16 respectively, I don't understand this error. I've been able to call other methods from this class. This is my first time trying to import functions from another language into Python. Any help understanding or correcting this error would be appreciated.

1

There are 1 answers

0
Chris-G On BEST ANSWER

I solved this by changing SetStreamDestination(LocalIP, LocalPort) to SetStreamDestination(LocalIP, UInt16(LocalPort))