Hi Sergio,
You might be comparing code in C# that uses the Excel-DNA ExcelRtdServer base class, with code form elsewhere in VB.NET that perhaps implements the IRtdServer interface directly.
I would suggest you base your VB.NET RTD server on the ExcelRtdServer base class too.
One sample that shows a minimal C# RTD server can be found here: https://github.com/Excel-DNA/Samples/blob/master/RtdClocks/RtdClock-ExcelRtdServer/RtdClockServer.cs
I pushed the file with the RTD server through the converter here: https://codeconverter.icsharpcode.net/
And the result looked like this:
Imports System.Collections.Generic
Imports System.Runtime.InteropServices
Imports System.Threading
Imports ExcelDna.Integration.Rtd
Namespace RtdClock_ExcelRtdServer
<ComVisible(True)> ' Required since the default template puts [assembly:ComVisible(false)] in the AssemblyInfo.cs
<ProgId(RtdClockServer.ServerProgId)> ' If ProgId is not specified, change the XlCall.RTD call in the wrapper to use namespace + type name (the default ProgId)
Public Class RtdClockServer
Inherits ExcelRtdServer
Public Const ServerProgId As String = "RtdClockVB.ClockServer"
' Using a System.Threading.Time which invokes the callback on a ThreadPool thread
' (normally that would be dangeours for an RTD server, but ExcelRtdServer is thrad-safe)
Private _timer As Timer
Private _topics As List(Of Topic)
Protected Overrides Function ServerStart() As Boolean
_timer = New Timer(AddressOf timer_tick, Nothing, 0, 1000)
_topics = New List(Of Topic)()
Return True
End Function
Protected Overrides Sub ServerTerminate()
_timer.Dispose()
End Sub
Protected Overrides Function ConnectData(ByVal topic As Topic, ByVal topicInfo As IList(Of String), ByRef newValues As Boolean) As Object
_topics.Add(topic)
Return Date.Now.ToString("HH:mm:ss") & " (ConnectData)"
End Function
Protected Overrides Sub DisconnectData(ByVal topic As Topic)
_topics.Remove(topic)
End Sub
Private Sub timer_tick(ByVal _unused_state_ As Object)
Dim now As String = Date.Now.ToString("HH:mm:ss")
For Each topic In _topics
topic.UpdateValue(now)
Next
End Sub
End Class
End Namespace
Let us know if that helps you to get the RTD server working.
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/c7eb269a-0b4f-4ec2-a1cc-5e190dba82b7n%40googlegroups.com.
You’re right, I compared ExcelRtdServer with IrtdServer interface.
Your code is very useful, many thanks but, when I try to debug I receive this error:
Managed Debugging Assistant 'LoaderLock'
Message=Managed Debugging Assistant 'LoaderLock' : 'Attempted execution within the OS Loader block. Do not try to run managed code inside a DllMain or image initialization function. This can cause the application to hang. ' (I translate from Italian😊).
Do you know how to solve it?
Thanks
Sergio
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/01d901d685e8%245d58b5d0%24180a2170%24%40icon.co.za.
HI Sergio,
That is an expected warning that comes when debugging, if the Excel-DNA IntelliSense service is installed.
You can safely check the box that lets you ignore this warning.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/000e01d685f5%24473c8a80%24d5b59f80%24%40gmail.com.
Wonderful, many thanks.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/022b01d685f5%24c05b50e0%244111f2a0%24%40icon.co.za.