ib-csharp icon indicating copy to clipboard operation
ib-csharp copied to clipboard

TWS returns bad AgentDescription "0" (started 2016-01-07) and throws InvalidCastException

Open DrKoch opened this issue 9 years ago • 1 comments

On Thursday 2016-01-07 my Application (usking krs.ats.ib-csharp) suddemly crashed with an InvalidCastException. I trcked this down to happen in IBClient.cs. TWS sends a bad code "0" for AgentDescription.

A possible fix looks like this: IBClient.cs, line 3770:

                    if (version >= 9)
                    {
                        rstr = ReadStr();
                        AgentDescription ad = AgentDescription.None;
                        if (!string.IsNullOrEmpty(rstr))
                        {
                            try
                            {
                                ad = (AgentDescription)EnumDescConverter.GetEnumValue(typeof(AgentDescription), rstr);
                            }
                            catch (Exception)
                            {

                                ad = AgentDescription.None;
                            }
                        }
                        order.Rule80A = ad;
                        order.PercentOffset = ReadDouble();

DrKoch avatar Jan 10 '16 13:01 DrKoch

Same issue here. Used your fix temporarily.

marcogruhl avatar Mar 11 '16 11:03 marcogruhl