[Quickfix-developers] Custom Messages and .Net Invoke
Brought to you by:
orenmnero
From: Andrew R. \(TT\) <and...@tr...> - 2008-06-23 17:29:53
|
I have developed a FIX GUI app which is an initiator. Thus, every time I receive an update, I pass it to the GUI as: public delegate void MessageListener(QuickFix.Message message); public MessageListener messageListeners; public void registerMessageListener(MessageListener ml) { messageListeners += ml; } public virtual void fromApp(QuickFix.Message message, QuickFix.SessionID sessionID) { if (_control != null && _control.InvokeRequired) { _control.Invoke(new MessageListener(messageListeners), new Object[] { message }); } } This has always worked great. Recently, the server to which I connect added a custom message that I needed to process. So I derived a new custom message. Specifically, I simply copied another 4.2 message from the C# QuickFIX source and modified it. I also created a custom message factory and added this new message to my data dictionary. Whenever I receive an update for a standard FIX message, everything still works fine. Whenever I receive an update for this new custom message, I get an invalid cast exception that points to my "_control.Invoke" line. System.InvalidCastException was unhandled Message="At least one element in the source array could not be cast down to the destination array type." Source="System.Windows.Forms" StackTrace: at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) at QuickFix.TTQuickFix.fromApp(Message message, SessionID sessionID) in C:\Documents and Settings\me\My Documents\Visual Studio 2005\Projects\MyApp\MyApp\MyApp.cs:line 168 at Application.fromApp(Application* , Message* message, SessionID* sessionID) Why is this an invalid cast? What did I forget? Any help would be appreciated. |