Trouble creating instance of Ethernet/IP class -Powershell

  Kiến thức lập trình

it keeps telling me the assemblies are not loaded (even though I have set them up at the top)

    # Load the EEIP.dll
    Add-Type -Path C:myDllsEIPEEIP.dll
    Add-Type Sres.Net.EEIP
    # Define PLC connection parameters
    $IPAddress = "192.168.1.190"
    $Timeout = 2000  # Timeout value in milliseconds
    try {
        # Create an instance of the Ethernet/IP communication class
        $plc = New-Object EthernetIP.EEIPClient
    }
    catch {
         Write-Host "Error communicating with PLC:" $_.Exception.Message
    }

it seems to work ok in VS (VS is also pointed to the same dll location specified in the PS script)

    using Sres.Net.EEIP;
    class Program
    {
        static void Main(string[] args)
        {
            EEIPClient eeipClient = new EEIPClient();
            eeipClient.RegisterSession("192.168.1.190");
            eeipClient.UnRegisterSession();
        }
    }

LEAVE A COMMENT