I have written a c# RTD server based off of Kenny Ker's Multiple Topics in C#
The main difference between his design and mine is that my data comes from a WCF client. I use the same type of timer and every couple of seconds I call m_callback.UpdateNotify();
. My RefreshData
method calls a function in my WCF client with the topic values and uses the result as the value for excel. It all works excellent.
The problem comes when I close excel.
When I close Excel I get a message box that says "Microft Excel has stopped working"
My ServerTerminate()
method clears all of my topics, calls close on my WCF client and exits without error.
I thought the problem might be a COM issue so I have tried adding
while ( Marshal.ReleaseComObject( m_callback ) > 0 ) ;
m_callback = null;
The pop up still showed up so I tried adding
GC.Collect();
GC.WaitForPendingFinalizers(); //SEHException thrown from this
GC.Collect();
GC.WaitForPendingFinalizers();
Adding these lines does throw an exception. if I ignore the exception excel closes without any problems, but if I install my RTD server on a computer with excel 2010, then the pop up box is still there.
I have Excel 2007 (12.0.6665.5003) SP3 MSO (12.0.6662.5000) I am developing my c# RTD Server using Visual Studio 2008 and my project has a reference to Microsoft.Office.Interop.Excel version 12.0.0.0