Skip to content

ArgumentOutOfRangeException when executing the method DBWrite #38

@PozitronikAkr

Description

@PozitronikAkr

Hi !

There is no physical connection.

The DBRead method predictably returns error number 9. CLI : Client not connected.
The DB Write method returns an exception System.ArgumentOutOfRangeException.
And it should, as it seemed to me, also return error number 9.
Why is this not the case?

namespace TestSharp7ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            int result;
            byte[] db = new byte[20];
            S7Client client = new S7Client();
            client.ConnectTo("192.168.0.2", 0, 1);
            try
            {                
                result = client.DBRead(10, 0, db.Length, db);
                Console.WriteLine($"{result} : {client.ErrorText(result)}");
                result = client.DBWrite(10, 0, db.Length, db);
                Console.WriteLine($"{result} : {client.ErrorText(result)}");
            }
            catch (System.ArgumentOutOfRangeException e)
            {
                result = -1;
                Console.WriteLine($"{result} : {e.Message}");
            }
            Console.WriteLine();
            Console.WriteLine("Press <Enter> for exit");
            Console.ReadLine();        
        }
    }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or requestgood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions