Lets take a simple example for it !!
Suppose this is our Pre-Update Plugin
{
Calculate myCalculate;
DynamicEntity entity = (DynamicEntity)context.InputParameters[ParameterName.Target];
if (entity.Name == EntityName.lead.ToString())
{
// Get the Last Name string
String lastName =(string) entity.Properties[“lastname”];
// Call the function within the assembly
myCalculate = new Calculate();
lastName=myCalculate.RemoveCharSwithN(lastName);
// Assign the value back
entity.Properties[“lastname”] = lastName;
}
}
This plugin would update the value for lastname field for
the lead record on pre update. It is making use of a
custom function which is there in some other assembly.
The function is a simple function which would replace the
char ‘s’ with ‘m’
return a.Replace(‘s’, ‘n’);
}
}
If we register the above plugin without putting Calculate class’s assembly in GAC, we would get the following error
“Count not load the file or assembly ‘Calculator’ or one of its dependencies”
Here we need to put the referenced assembly in the GAC,
followed by an IISReset.
Or the other option with us is to use ILMerge tool. Using it we can combine multiple .NET assemblies into one.
Download and find more information about the tool here
http://research.microsoft.com/en-us/people/mbarnett/ILMerge.aspx
Using the following command we can merge multiple assembly into one
ilmerge /keyfile:g.snk Test.dll Calculator.dll /out:ILMergedLibrary.dll
keyfile –> valid key file
Test.dll—> the plugin’s dll
Calculator.dll—> the custom assembly.
ILMergedLibrary.dll –> The resulting assembly.
And register this newly merged assembly.
Bye.
Discover more from Nishant Rana's Weblog
Subscribe to get the latest posts sent to your email.
