web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Can't get any tracing info for plugin in CRM 2011 Online

(0) ShareShare
ReportReport
Posted on by 30

Hi,

I have to create a plugin for CRM 2011 Online.

Since I am new to Microsoft Dynamics CRM I followed some tutorials on how to create plugins.

I successfully created a plugin in VS2012 and uploaded it to the CRM server using the Plugin Registration Tool from the CRM SDK. I Registered the plugin to be executed whenever a contact is retrieved.

When opening a contact all goes well so I assume that my plugin is executed OK.

In order to view the tracing that I added to my code, I added a 'throw new Exception' at the end of my execute method. When doing this, the application results in a 'Business Process Error' (as expected) but no tracing is shown. Does anyone know what is missing??

My plugin code is the following: 

public class TracePlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService = serviceProvider.GetService(typeof(ITracingService)) as ITracingService;
if (tracingService == null)
{
throw new InvalidPluginExecutionException("Failed to retrieve the ITracingService");
}
tracingService.Trace("TracingService Initialized ...");
IPluginExecutionContext context = serviceProvider.GetService(typeof(IPluginExecutionContext)) as IPluginExecutionContext;
if (context == null)
{
throw new InvalidPluginExecutionException("Failed to retrieve the ITracingService");
}
tracingService.Trace("Context Initialized ...");
Entity entity;
// Check the input parameters property bag
// - It should contain a target
// - The target is of type Entity
// - The Entity is a contact
bool validInput = true;
if (context.InputParameters.Contains("Target"))
{
// Obtain the target business entity from the input parameters.
entity = context.InputParameters["Target"] as Entity;
if (entity != null)
{
// Verify that the entity represents a contact.
if (entity.LogicalName != "contact")
{
tracingService.Trace(string.Format("Target Entity should be of type 'contact' in stead of '{0}'", entity.LogicalName));
validInput = false;
}
}
else
{
tracingService.Trace(string.Format("InputParameter 'Target' should be of type 'Entity'"));
validInput = false;
}
}
else
{
tracingService.Trace(string.Format("InputParameters do not contain 'Target'"));
validInput = false;
}
if (validInput)
{
tracingService.Trace(string.Format("All Parameters Initialized"));
// TODO: IMPLEMENT CODE HERE
}
//throw new InvalidPluginExecutionException("Hello, this is your tracer speaking ...");
}
}

 

 

*This post is locked for comments

I have the same question (0)
  • apurv Profile Picture
    926 on at

    Hi Erwin,

    I have written a small sample for the same operation. You might want to check this out

    IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
     IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
                ITracingService tracingService =
                 (ITracingService)serviceProvider.GetService(typeof(ITracingService));
                tracingService.Trace("Started plugin execution ");
                           if (context != null)
                {
                    throw new InvalidPluginExecutionException("Failed to retrieve the ITracingService");
                }
                tracingService.Trace("Create Done ");

    }

    Here you'll be able to see the business process error with a message "Failed to retrieve the ITracingService" and once you will download the log file. You will find a trace line "Started plugin execution". However the last line will not be printed because the exception occurred before the operation could be completed.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans