During plug-in development, we need to troubleshoot our plug-in code for different errors that we may face during execution of the code. It is always a good practice to have your code well documented with proper exception handling. We can troubleshoot plug-in code in three ways:
Using the
ITracingService
service.Using debugging.
Writing logs to text files.
ITracingService
helps us to generate logging information that we may want to do at different steps. This is especially useful when we don't have debugging tools available and need logging information to troubleshoot our code. We can get ITracingService
from the service provider object as follows:
//Extract the tracing service for use in debugging sandboxed plug-ins. ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
ITracingService
has one method Trace
that we can use to create logs as follows:
//adding log information tracingService.Trace("Logging Message");
All the...