Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 137182

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

$
0
0

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 ...");
}
}

 

 


Viewing all articles
Browse latest Browse all 137182

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>