When i start my project it runs fine and UI is loaded and when i click the button after entering values, it shows error.At button click i have called a method.
private void button_Click(object sender, RoutedEventArgs e)
{
CompositionHelpers.CalculatorComposition calc = new CompositionHelpers.CalculatorComposition();
var result = calc.GetResult(Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text));
textBox3.Text = result.ToString();
}
Method is called from the file:
public class CalculatorComposition
{
[Import(typeof(ICalculator))]
public ICalculator CalciPlugin { get; set; }
public void AssembleComponents()
{
try
{
var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
var container = new CompositionContainer(catalog);
container.ComposeParts(this);
}
catch (Exception ex)
{
throw ex;
}
}
public int GetResult(int num1, int num2)
{
return CalciPlugin.GetNumber(num1, num2);
}
}
which enforces contract:
public interface ICalculator
{
int GetNumber(int Num1, int Num2);
}
Please help me out to resolve this issue.
we are using managed extensibility framework?
What I have tried:
I have tried to reslove the issue but it is still present?