MEF Sample: Simple Calculator (Visual Basic)
The simplest way to see what Managed Extensibility Framework can do is to build a simple MEF application. In this example, you build a very simple calculator named SimpleCalculator. The goal of SimpleCalculator is to create a console application that accepts basic arithmetic commands, in the form "5+3" or "6-2", and returns the correct answers. Using MEF, you will be able to add new operators without changing the application code.
NOTE: The purpose of SimpleCalculator is to demonstrate the concepts and syntax of MEF, rather than to necessarily provide a realistic scenario for its use. Many of the applications that would benefit most from the power of MEF are more complex than SimpleCalculator. For more extensive examples, see Managed Extensibility Framework samples.
Building the sample
To download and run the sample, follow these steps:
Download and unzip the sample.
In Visual Studio 2019 or later:
On the menu bar, choose File > Open > Project/Solution.
Navigate to the folder that holds the unzipped sample code, and open the solution (.sln) file.
Press F5 or Ctrl+F5 to run the project.
From the command line:
Navigate to the folder that holds the unzipped sample code.
At the command line, type
dotnet run
.