Reply To: CodeSite 5.3.3 – TCP and background services, dispatcher as a service.

Home Forums CodeSite CodeSite 5.3.3 – TCP and background services, dispatcher as a service. Reply To: CodeSite 5.3.3 – TCP and background services, dispatcher as a service.

#1414
Ray Konopka
Keymaster

    Hi Warren,

    Sending CodeSite messages from service apps is a bit tricky because of 2 reasons. The first is the communication restriction that Microsoft has placed between window stations. And the second is the communication method that CodeSite uses to send messages.

    When you are trying to send CodeSite messages from a service app, you have two choices. The first is to change the communication method that the CodeSite Logger classes use to send messages to the CodeSite Dispatcher. The default method uses wm_CopyData window messages. However, window messages are no longer allowed to be sent across window stations. Therefore, you can switch the method to use TCP. To do this, you need to call the ConnectUsingTcp() method on the CodeSiteManager (or on an individual logger instance). The logger classes will then use TCP to send the CodeSite messages to the Dispatcher, which is presumably running on the currently logged in users desktop (window station). In this case, Live Logging will continue to work because the Dispatcher will be able to send wm_CopyData window messages to the CodeSite Live Viewer (also running on the desktop).

    The other way of using CodeSite in a service application is to actually run the CodeSite Dispatcher as a service. In this case, the Dispatcher is running in the same window station as the service app and the wm_CopyData messages will get through from the logging classes to the Dispatcher. This arrangement is typically used when you need to log information from the service app and there is no active user and no user desktop. Furthermore, in this arrangement, you can really only send CodeSite messages to a log file and not the Live Viewer. The reason Live Logging does not work, is related to the information described above. The Dispatcher is running in the Service space and the Live Viewer is running (if it is running) in a user’s desktop station. The Dispatcher uses wm_CopyData to send messages to the Live Viewer–and unlike the Logging Classes to Dispatcher communication which can be changed to TCP, the Dispatcher to Live Viewer communication cannot.

    So, I hope the above helps clarify things for you. If you do not need to run the Dispatcher as a service, (as described above), then I would run it as a normal app and then just call the ConnectUsingTcp method on the CodeSiteManager inside your service app code (before trying to send any CodeSite messages), and then you should be able to see your CodeSite messages appear in the Live Viewer.

    Ray