CAB Quickie – The Plug-in Application: The Main Application (Part 2)
In this part, you will add the “main application”. It will be a “Hello World!” application that will act as the program you are about to extend using a plug-in system based on CAB.
First of all, you will create a new Windows Application project.
1. Return to the PluginQuickie blank solution and, in Visual Studio, point to Add on the File menu, and then click New Project.
Figure. Creating the MainApplication project.
2. In the New Project dialog box, expand the Visual C# node. Click the Windows project type.
3. In the Templates window, select Windows Application.
4. Change the Name to MainApplication.
5. Change the location for the solution to the source folder located inside the PluginQuickie folder.
6. Click OK.
Figure. The MainApplication project.
As I wrote in the CAB Quickie – The Plug-in Application: Setting up the development environment post, the bin\Debug folder was created to contain all the built projects, so you need to change the output path of the MainApplication project to this folder. To accomplish this, right-click the MainApplication project (in the Solution Explorer) and select Properties. In the Build tab, go to the Output section and edit the Output path to %PluginQuickieFolder%\bin\Debug.
Figure. Output path in the Output section located at Build tab in the Project properties. Note: you might not see a relative path until you close the properties window and open it again.
After doing this, you’ll start setting up the MainForm:
1. In the Solution Explorer, right-click the Form1.cs file, select Rename, and change the name to MainForm.cs.
2. In the Designer, right-click the MainForm and select Properties.
3. Set the following values to the corresponding properties:
| Property | Value |
| Size | 300, 300 |
| StartPosition | CenterScreen |
| Text | MainForm |
4. Add a Label to the MainForm with the following values set to the corresponding properties:
| Property | Value |
| (Name) | HelloWorldLabel |
| Font | Arial, 20,25pt, style=Bold |
| Location | 61, 115 |
| Text | Hello World! |
5. Add a MenuStrip to the MainForm and name it HelloWorldMenuStrip.
6. Add a ToolStripMenuItem in the HelloWorldMenuStrip by typing “&File” in the “Type Here” box, and another one inside the fileToolStripMenuItem (this name is given when the item is added) by typing “&Exit” (which will be named exitToolStripMenuItem).
7. Double-click the exitToolStripMenuItem to generate the code for the handler for the click event of the menu item and add the following code line inside:
Application.Exit();
NOTE: This will close the application when clicking on the exitToolStripMenuItem.
8. Once you have done this, in the Designer, right-click the MainForm, select Properties, and set the MainMenuStrip property to the HelloWorldMenuStrip menu strip.
When all these steps are done, just save, compile and run the project. You will see an ordinary Hello World application. So far, we haven’t seen anything about CAB yet.
Figure. Outcome: The MainApplication.
Next Steps
In the next part, you will add the CAB plug-in application (that will be another Windows Application with references to the CAB assemblies).
[...] no spoon!” « CAB Quickie – The Plug-in Application (Overview) CAB Quickie – The Plug-in Application: The Main Application (Part 2) [...]
[...] Create the “Hello World!” application: you will add a Windows Application to the blank solution and set it up to be the Main application. [...]