I have an application where I use TraceListener to collect data/debugging information while application executes. There are more than one listeners at the same time, one of them will write trace information to disk file, other may collect in string (for a short period of execution) and then it will be displayed to user or might saved to another file as per needs.
All went well, unless we decided something else.
We had lot of plugins which were loaded at runtime and executed. However, the issue with that was it was hard to replace the plugin DLL since it was used by application, so we had to stop and replace DLL and then start it again. We decided to use appDomain to load plugin into so that we can easily replace DLL without restarting the application(s). That was also went well, but one major issue came in. the trace listerns were blind. Since the plugins are loaded into different app domain, so the traces never reached to the parent app domain which was listening to it (the traces made by plugin, which is loaded into new appdomain).
Our trace listener looks like this.
Public Class StringTraceListener
Inherits TextWriterTraceListener
Dim sw As System.Text.StringBuilder = Nothing
Public Overrides Sub WriteLine(ByVal message As String)
Try
MyBase.WriteLine(message)
sw.AppendLine(Now.ToString & " : " & message)
Catch ex As Exception
'Do not write anything here... or it might go into recursive loop
End Try
End Sub
I wonder, if there is a way that we don’t have to make much changes and the trace listener might receive traces from plugins (child appDomain) as well? Any idea will be appreciated Thanks