I am creating a new plugin in a new project within a pre-existing Microsoft Dynamics CRM 4 solution in Visual Studio 2010. This solution already contains other projects/DLLs that have been successfully deployed using the plugin registration tool.
However, when I build my project and load the .dll file into the plugin registration tool, no plugins are picked up in the loaded assembly!
My plugin class contains the IPlugin interface and has been signed. I don't know what else I need to do? Does anyone have any advice?
UPDATE: My Class -
As you can see I've kept it simple for this first test deployment.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Query;
using Microsoft.Crm.SdkTypeProxy;
using System.Web;
using System.Xml;
using System.Runtime.InteropServices;
namespace RI.CRM.Plugins2
{
class SupportAutoNumber : IPlugin
{
public void Execute(IPluginExecutionContext context)
{
if (context == null) throw new InvalidPluginExecutionException("Context is null.", new ArgumentNullException("context"));
// Verify that there is an entity in the target
if (context.InputParameters.Properties.Contains(ParameterName.Target)
&& context.InputParameters.Properties[ParameterName.Target] is DynamicEntity)
{
ICrmService crmService = context.CreateCrmService(true);
DynamicEntity theAutonumber = RetrieveDynamicEntitiesByProperty(crmService, "ri_autonumber", "ri_name", "Support Ticket Numberer");
throw new InvalidPluginExecutionException(string.Format("Retrieved Autonumber: {0}", theAutonumber.Name));
}
}
public static DynamicEntity RetrieveDynamicEntitiesByProperty(ICrmService service, string Entity, string Column, string Value)
{
ConditionExpression con = new ConditionExpression();
con.AttributeName = Column;
con.Operator = ConditionOperator.Equal;
con.Values = new string[] { Value };
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.And;
filter.AddCondition(con);
QueryExpression query = new QueryExpression();
query.EntityName = Entity;
query.ColumnSet = new AllColumns();
query.Criteria = filter;
RetrieveMultipleRequest retrieve = new RetrieveMultipleRequest();
retrieve.Query = query;
retrieve.ReturnDynamicEntities = true;
RetrieveMultipleResponse retrieved = (RetrieveMultipleResponse)service.Execute(retrieve);
//I prefer Lists to BusinessEntityCollection objects
IList<DynamicEntity> Entities = new List<DynamicEntity>();
foreach (DynamicEntity de in retrieved.BusinessEntityCollection.BusinessEntities)
Entities.Add(de);
if (retrieved.BusinessEntityCollection.BusinessEntities.Count == 0)
return null;
DynamicEntity entity = (DynamicEntity)retrieved.BusinessEntityCollection.BusinessEntities[0];
return entity;
}
}
}