Inside Microsoft Dynamics CRM 3.0

Arne Janning

  Home  |   Contact  |   Syndication    |   Login
  3 Posts | 0 Stories | 13 Comments | 51 Trackbacks

News

Archives

MSCRM blogs I read

Wednesday, November 16, 2005 #

So let's simply start this blog.

One of my goals is to show how one can inject custom code in CRM 3.0 - I'm not talking about callouts or supported and documented stuff (of course I will write about this as well on this blog) - I'm talking about changing the internal objects and data structures at runtime.

To that end we will have to look a lot at the code Reflector gives us, to see what's really going on under the hood. To that same end - and for many other things - using the built-in tracing-mechanism is really useful to see what MSCRM actually does.

Although there is a section "Registry Settings" in the SDK it is not documented how to enable tracing.

But Reflector shows that there is a class called CrmTrace in Microsoft.Crm.dll. The method Microsoft.Crm.CrmTrace.LoadTrace() : Boolean shows the registry keys that are necessary to enable tracing:

private static bool LoadTrace()
{
      string[] textArray2;
     //[...]
     textArray2 = new string[] { "TraceEnabled", "TraceSchedule", "TraceCallStack", "TraceCategories" } ;
     //[...]
     text1 = "TraceEnabled";
     CrmTrace.isTracingOff = ((int) RegistryCache.GetValue("TraceEnabled")) == 0;
     //[...]

 

So to enable the tracing-mechanism you simply have to add some registry keys to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM:

  • TraceEnabled (dword) - set the value to 1 to turn on tracing, set the value to 0 to turn it off again
  • TraceDirectory (string) - this is the directory where the trace files are stored. The directory has to exist, CRM will not create the directory.
  • TraceCategories (string) - set the value to *:Verbose
  • TraceCallStack (dword) - set the value to 1 if your're interested in the stack trace
  • TraceRefresh (dword) - set the value to 1
  • TraceSchedule (string) - set it to one of the values of the Microsoft.Crm.TraceSchedule-enum: e.g. Daily or Hourly

It is not necessary to restart IIS, MSCRM 3.0 has a mechanism of getting notified of configuration-changes at runtime. This mechanism gets started by the Microsoft.Crm.MainApplication.Application_OnStart()-method in Microsoft.Crm.Application.Pages.dll:

NotificationManager.StartNotificationsThread(new Notification());

Microsoft.Crm.MainApplication.Application_OnStart() is the main entrypoint for the whole MSCRM-application. We will speak about this later in much greater detail.

To be continued...