Calling System.Diagnostics.Trace from Dynamics CRM 2011 Plugin

I wonder if any of you have any ideas on the next issue I am facing.

Here are some super simple plugins.

namespace Demo.DebugTraceBlog { public class TraceAndDebugDemo : IPlugin { public void Execute(IServiceProvider serviceProvider) { Trace.WriteLine("Started Plugin"); Trace.WriteLine("Plugin Working"); Trace.WriteLine("Ending Plugin"); } } } 

Im using DebugView (http://goo.gl/YRfus) to view the recorded Trace messages. When I run this code as a plug-in running in the sandbox, I get the expected results: three lines appear in the DebugView, and if I attach the VS to the Sandbox workflow, I see three lines written in the output window. Now, when I change the isolation mode to none, and let it start in the W3WP.EXE process, I don’t get any output in DebugView, and when I connect to W3WP.EXE, I can set a breakpoint to check if it works, but I don’t get any output in the output window.

Any idea on why this is happening, and how I can get around the cause and make non-sandbox execution work properly. I can guess that this is due to running within the IIS CRI processes and that CRM suppresses the trace record - I specifically used Trace instead of Debug in an attempt to avoid this problem, but no luck.

I know that I can use ITracingService, but this does not meet my current requirements.

+7
source share
1 answer

(Guess) Add this to your configuration file. If this worked, then your problem is that the .NET trace has some problems with its default receiver when it is in a different application domain.

Change D:\Log\MyApp\Program to the path to which ASP.NET has full access.

 ... <system.diagnostics> <switches> ... </switches> <sources> ... </sources> <trace autoflush="true"> <listeners> <clear /> <add name="defaultListener" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter" Append="true" AutoFlush="true" BaseFileName="program" CustomLocation="D:\Log\MyApp\Program" DiskSpaceExhaustedBehavior="DiscardMessages" Encoding="Unicode" IncludeHostName="false" LogFileCreationSchedule="Daily" location="Custom" MaxFileSize="900000000000" /> <add name="programConsoleListener" type="System.Diagnostics.ConsoleTraceListener" /> </listeners> </trace> </system.diagnostics> ... 
+2
source

All Articles