Deploying a multiple assembly plugin

Lets take a simple example for it !!

Suppose this is our Pre-Update Plugin

public void Execute(IPluginExecutionContext context)
{
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’
 
public class Calculate{public string ReplaceCharSwithN(string a){

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.

 


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s