danikf / tik4net

Manage mikrotik routers with .NET C# code via ADO.NET like API or enjoy O/R mapper like highlevel api.
Apache License 2.0
177 stars 94 forks source link

LoadAll method throwing exception System.FormatException: 'Value 'established,related,untracked' for property 'ConnectionState(connection-state)' is not in expected format #94

Open kuski-jabir opened 10 months ago

kuski-jabir commented 10 months ago

I was following the documentation in order to apply firewall filter to a mikrotik router.
`

        try
        {

            using (var tikConnection = ConnectionFactory.OpenConnection(TikConnectionType.Api, routerApiAddress, username", password))
            {
                var firewallFilter = new FirewallFilter()
                {
                    Chain = FirewallFilter.ChainType.Forward,
                    Action = FirewallFilter.ActionType.Drop

                    //ConnectionBytes = 0
                };
                tikConnection.Save(firewallFilter);

                 var loaded = tikConnection.LoadAll<FirewallFilter>().First();

        }
        catch (Exception ex)
        {
            result.TechnicalMessage = ex.Message;
            result.IsOkay = false;
            return result;
        }

    `

however the following exception is thrown when i try to retrieve the applied rules. System.FormatException: 'Value 'established,related,untracked' for property 'ConnectionState(connection-state)' is not in expected format 'tik4net.Objects.Ip.Firewall.FirewallFilter+ConnectionStateType'.'

Adding the ConnectionState Property didn't change the error ` var firewallFilter = new FirewallFilter() { Chain = FirewallFilter.ChainType.Forward, Action = FirewallFilter.ActionType.Drop, ConnectionState = FirewallFilter.ConnectionStateType.New

                    //ConnectionBytes = 0
                };`

The same behavior was replicated when using DeleteAll and LoadList methods. tik4Net version 3.50