Asked by:
Plugin registered but not getting fired

Question
-
It seemed working a month ago, but don't know what happened now.
I am registering plugins using the RegisterSolutionRequest class and I am able to see the plugins registered, but they are not getting fired. There is no error, while I run the code or while debugging, but they do not get fired. Here is the code I used:
Irrespective of whether a plugin is already registered, I first unregister and then register the plugins.
public void Register(string organization, string userSpecifiedAssembly, string userSpecifiedServer, string registerFilePath)
{
try
{
Console.Write("\n\nStarting to register assembly.");
Organization = organization;// Get the plug-in assembly.
Console.Write("\nLoading assembly file..");
Assembly dll = Assembly.LoadFile(string.IsNullOrEmpty(userSpecifiedAssembly) ? PluginFile : userSpecifiedAssembly);Console.Write("\nRetrieving assembly properties..");
// Create the plug-in assembly.
pluginassembly assem = new pluginassembly();
assem.name = dll.GetName().Name;
assem.sourcetype = new Picklist();// Note: SourceType 0 is "Database".
assem.sourcetype.Value = 0;
//assem.culture = dll.GetName().CultureInfo.ToString() == "" ? "neutral" : dll.GetName().CultureInfo.ToString();
assem.culture = dll.GetName().CultureInfo.ToString();
if (String.IsNullOrEmpty(assem.culture))
{
assem.culture = "neutral";
}
assem.version = dll.GetName().Version.ToString();Byte[] tokenBytes = dll.GetName().GetPublicKeyToken();
StringBuilder strBuilder = new StringBuilder(32);
foreach (byte b in tokenBytes)
{
strBuilder.Append(b.ToString("x").PadLeft(2, '0'));
}
assem.publickeytoken = strBuilder.ToString();//Load the file into pluginassembly.content
FileInfo fInfo = new FileInfo(dll.Location);
using (FileStream fs = File.OpenRead(dll.Location))
{
byte[] buffer = new byte[fInfo.Length];
fs.Read(buffer, 0, (int)fInfo.Length);
int outputSize = (int)Math.Ceiling(fInfo.Length / 3d) * 4;
char[] output = new char[outputSize];
System.Convert.ToBase64CharArray(buffer, 0, buffer.Length, output, 0);
assem.content = new string(output);
}Console.Write("\nRetrieving Plugin Steps..");
SdkMessageProcessingStepRegistration[] steps = GetStepsInformation(dll, registerFilePath);
//Create a register request.
RegisterSolutionRequest request = new RegisterSolutionRequest();
request.PluginAssembly = assem;
request.Steps = steps;Console.Write("\nRegistering assembly..");
//Execute the register request.
RegisterSolutionResponse response = (RegisterSolutionResponse)GetCRMService(userSpecifiedServer).Execute(request);
Console.Write("\nSuccessfully regsitered assembly.");
}
catch (System.Exception ex)
{
throw new Exception("Error while registering. Error message:" + ex.Message);
}
}Any help please. Thanks
Thursday, August 19, 2010 4:45 PM
All replies
-
You need to restart IIS or reset the CRMAppPool for updated plugins to be used by CRM
MSCRM Bing'd - http://bingsoft.wordpress.comThursday, August 19, 2010 4:46 PMModerator -
I did that, but still doesn't work. Thanks.Thursday, August 19, 2010 4:52 PM
-
Could it be becuase we have two organizations.
I added this in the code
assem.organizationid =
new Lookup();
assem.organizationid.name =
"XXCRMDEV";
assem.organizationid.Value =
new Guid("XXXXXXXX");
Thursday, August 19, 2010 5:45 PM -
still doesn't work.Thursday, August 19, 2010 5:46 PM
-
Hi Glora,
have you tried using plug in registration tool?
http://code.msdn.microsoft.com/crmplugin
MayankP My Blog My twitterFriday, August 20, 2010 9:13 AM