How to: Build and Run the ShapeAppBasicMFC Sample
The ShapeAppBasicMFC sample demonstrates how to integrate Visual Studio Tools for Applications with a host application that is written in unmanaged code.
For more information about the ShapeAppBasicMFC sample, see ShapeApp Samples (Visual Studio Tools for Applications).
Building and Running ShapeAppBasicMFC
To build and run ShapeAppBasicMFC, perform the following steps:
Install Visual Studio Tools for Applications.
Extract ShapeAppBasicMFC.
Open ShapeAppBasicMFC in Visual Studio and build it.
Register ShapeAppBasicMFC. This enables you to build and debug the sample add-in, and to use the project templates that are included with ShapeAppBasicMFC to create your own add-ins.
Build the sample add-in.
Load the sample add-in into ShapeAppBasicMFC.
Optionally, unregister ShapeAppBasicMFC. This removes the registry entries that enable you to build and debug the sample add-in, and to use the project templates that are included with ShapeAppBasicMFC to create your own add-ins.
To extract ShapeAppBasicMFC
Create a folder named ShapeAppSamples at the root of the Windows system drive (%SystemDrive%), and then create a subfolder named ShapeAppBasicMFC. For example, if your system drive is C, the directory would be C:\ShapeAppSamples\ShapeAppBasicMFC.
Note
Although you can extract ShapeAppBasicMFC to any folder, the following procedures and the walkthroughs in the Visual Studio Tools for Applications documentation assume that you extract ShapeAppBasicMFC to the drive:\ShapeAppSamples\ShapeAppBasicMFC folder.
Open the Visual Studio Tools for Applications samples folder.
By default, the samples folder is located at %ProgramFiles%\Visual Studio Tools for Applications 2.0 SDK\build number\Visual Studio Tools For Applications\Samples on 32-bit versions of Windows, or at %ProgramFiles(x86)%\Visual Studio 2008 Tools for Applications SDK\build number\Visual Studio Tools For Applications\Samples on 64-bit versions of Windows.
Right-click the ShapeAppBasicMFC.zip file, and then click Extract All.
Note
This step assumes that your system is set to open .zip files using Compressed (zipped) Folders. If your system is set to open .zip files with another program, follow the instructions of that program to extract the contents of ShapeAppBasicMFC.zip.
Follow the instructions in the Extract Compressed (Zipped) Folders wizard to extract the contents of ShapeAppBasicMFC.zip to the drive:\ShapeAppSamples\ShapeAppBasicMFC folder.
To build ShapeAppBasicMFC
Start Visual Studio 2008. If you are using Windows Vista as your operating system, start Visual Studio 2008 by using the Run as Administrator option.
On the File menu, point to Open, and then click Project/Solution.
In the Open Project dialog box, navigate to the drive:\ShapeAppSamples\ShapeAppBasicMFC folder.
Select the ShapeAppBasicMFC.sln file, and then click Open.
On the Build menu, click Build Solution. Verify that the solution builds without errors.
On the File menu, click Close Solution.
To register ShapeAppBasicMFC
Open a Command Prompt window. If you are using Windows Vista as your operating system, open a Command Prompt window by using the Run as Administrator option.
Run the following command:
cd "%SystemDrive%\ShapeAppSamples\ShapeAppBasicMFC"
Note
If your development computer has a 64-bit operating system, make sure that you open a 32-bit Command Prompt window. The script file that registers ShapeAppBasicMFC can be run only in a 32-bit Command Prompt window.
Type the following command to run the SetupShapeAppBasicMFC.js script file. This script file registers ShapeAppBasicMFC with Visual Studio Tools for Applications and configures the project templates so that they can be used from Visual Studio 2008.
cscript SetupShapeAppBasicMFC.js
For more information about registering host applications, see Registering the Host Application.
Note
This command might require several minutes to complete.
To build the sample add-in
On the File menu, point to Open, and then click Project/Solution.
In the Open Project dialog box, navigate to the drive:\ShapeAppSamples\ShapeAppBasicMFC\Sample AddIns\CSharp folder.
Note
The following instructions assume that you are building the Visual C# version of the add-in. For a Visual Basic version of the add-in, see the drive:\ShapeAppSamples\ShapeAppBasicMFC\Sample AddIns\VisualBasic folder.
Select the ShapeAppMFCAddIns.sln file, and then click Open.
On the Build menu, click Build Solution. Verify that the solution builds without errors.
When you build the solution, the add-in assemblies are automatically copied as follows:
For Windows XP and Windows Server 2003:
- ShapeAppCSharpAppAddIn.dll is copied to %UserProfile%\My Documents\ShapeAppMFC\AppAddIns\ShapeAppMFCAppAddIn.
For Windows Vista:
- ShapeAppCSharpAppAddIn.dll is copied to %UserProfile%\Documents\ShapeAppMFC\AppAddIns\ShapeAppMFCAppAddIn.
ShapeAppBasicMFC searches for add-ins in this directory.
On the File menu, click Close Solution.
To load the add-in into ShapeAppBasicMFC
On the File menu of Visual Studio, point to Open, and then click Project/Solution.
In the Open Project dialog box, navigate to the drive:\ShapeAppSamples\ShapeAppBasicMFC folder.
Select the ShapeAppBasicMFC.sln file, and then click Open.
Press F5. Verify that ShapeAppBasicMFC displays the message "Drawing Created".
Close ShapeAppBasicMFC.
To unregister ShapeAppBasicMFC
Open a Command Prompt window. If you are using Windows Vista as your operating system, open a Command Prompt window by using the Run as Administrator option.
Run the following command.
cd "%SystemDrive%\ShapeAppSamples\ShapeAppBasicMFC"
Note
If your development computer has a 64-bit operating system, make sure that you open a 32-bit Command Prompt window. The script file that unregisters ShapeAppBasicMFC can be run only in a 32-bit Command Prompt window.
Type the following command to run the RemoveShapeAppMFC.js script file. This script file removes registry entries that enable you to build and debug the sample add-in, and to use the project templates that are included with ShapeAppBasicMFC to create your own add-ins.
cscript RemoveShapeAppMFC.js
Note
This command might require several minutes to complete.
See Also
Tasks
How to: Build and Run the ShapeAppCSharp Sample
How to: Build and Run the ShapeAppBasicCSharp Sample
How to: Build and Run the ShapeAppMacroRecordingCSharp Sample
How to: Build and Run the ShapeAppDynamicProgrammingModelCSharp Sample
How to: Build and Run the ShapeAppClickOnceCSharp Sample
Walkthrough: Integrating Visual Studio Tools for Applications with ShapeApp