Quick Start #1: Deploying a Document and an Assembly to a Local Folder
Note: We are pleased to present the first in a new set of deployment "quick start" topics that we are adding to the Visual Studio 2005 Tools for Office documentation in the coming months. Our customers have consistently listed deployment near the top of the list of issues that they want more help with. Although our current documentation covers deployment in detail, we felt the need for more topics that provide detailed, end-to-end instructions for deploying a Visual Studio 2005 Tools for Office solution in a specific scenario.
We will be publishing an initial set of four deployment quick starts to this blog over the next few days, and more will follow in the coming weeks. Although these new topics are not included in the documentation that will ship with Visual Studio 2005 Tools for Office at RTM, they will be added to the Visual Studio 2005 Tools for Office documentation on the MSDN Web site in the coming months, and they might also be included in a future documentation update. In the meantime, we wanted to publish them on our blog site to get them out in the public eye sooner rather than later. You have an opportunity to help guide the future content of our documentation. If you find these topics useful, or not useful, or if you have other specific deployment scenarios or Visual Studio 2005 Tools for Office development issues that you would like to see documented in one of these new topics, please let us know by leaving us a comment below!
The first four quick starts focus on relatively simple deployment scenarios that don't use the Publish Wizard or deployment manifests. This first quick start shows how to deploy a Word or Excel solution so that both the document and the assembly are in the same folder on the end user computer. The other quick starts that we will publish this week show the steps for other simple scenarios, such as deploying the assembly to a network folder. Future quick starts will focus on other deployment scenarios that use the Publish Wizard and deployment manifests. We also intend to provide some quick starts for Outlook add-in deployment.
Other Quick Starts in this series that are now available include:
- Deploying a Document and an Assembly to Different Local Folders
- Deploying a Document to a Local Folder, and an Assembly to a Network Folder
- Deploying a Document and an Assembly to a Network Folder
Now, on to the first quick start!
-----
Quick Start: Deploying a Document and an Assembly to a Local Folder
This Quick Start demonstrates how to deploy a Microsoft Visual Studio 2005 Tools for the Microsoft Office System solution for Microsoft Office Word 2003 or Microsoft Office Excel 2003 so that the document and the assembly are located in the same folder on the end user computer. This Quick Start is intended for users who have little or no experience with deploying Visual Studio 2005 Tools for Office solutions.
This Quick Start includes the following sections:
- Prerequisites
- Creating a Solution to Deploy
- Deploying the Solution
- Setting Security Policy
- Next Steps
Prerequisites
This Quick Start assumes the end user computer already has the following prerequisites installed for running Visual Studio 2005 Tools for Office solutions:
- A version of Word or Excel that supports Visual Studio 2005 Tools for Office.
- The primary interop assemblies (PIAs).
- The .NET Framework 2.0.
- The Visual Studio 2005 Tools for Office runtime.
This Quick Start does not show you how to install these prerequisites on the end user computer. For more information about the prerequisites, see How to: Prepare End User Computers to Run Office Solutions.
Creating a Solution to Deploy
In the following steps, you will create a basic Visual Studio 2005 Tools for Office solution to deploy. If you already have a solution that you want to deploy, you can skip this section and proceed to the Deploying the Solution section below.
Create a new Excel Workbook or Word Document project. For more information, see How to: Create Visual Studio Tools for Office Projects.
In Solution Explorer, right-click the ThisWorkbook (for Excel) or ThisDocument (for Word) code file and click View Code.
Add the following code in the ThisWorkbook_Startup (for Excel) or ThisDocument_Startup (for Word) event handler. This code displays a message box when the document opens, which will make it easy to verify whether the solution has been deployed successfully.
' Visual Basic
MessageBox.Show("The deployment is successful")
// C#
MessageBox.Show("The deployment is successful");
For more information about the Startup event, see Visual Studio Tools for Office Project Events.
Press F5 to build and run the project. Verify that the message box appears.
Deploying the Solution
In the following steps, you will deploy the document and assembly to the same folder on the end user computer.
- Choose or create a folder on the end user computer to deploy the solution to. If an end user computer is not currently available, you can choose or create a folder on your development computer to deploy the solution to.
- Copy the document and assembly from the build output folder (typically <project folder> \bin\debug or <project folder> \bin\release) to the folder you want to deploy the solution to.
- Open the document in the deployment folder. You will see an error message that states that the current .NET security policy does not permit the customization to run. This is because you have not granted full trust to the assembly yet.
- Click OK, and then close the document.
Setting Security Policy
In the following steps, you will grant full trust to the assembly in the .NET Framework 2.0 security policy of the end user. This Quick Start shows how to grant full trust to the assembly using the Code Access Security Policy tool (Caspol.exe). For more information about using Caspol.exe, see Code Access Security Policy Tool (Caspol.exe) and Configuring Security Policy Using the Code Access Security Policy Tool (Caspol.exe).
Security Note: These are basic steps for setting a security policy based on URL evidence for the purpose of completing this Quick Start. Do not use these steps to grant trust to assemblies in a real-world solution if you are not certain that the location is safe and secure. You should also base the security of a real-world solution on more evidence than the URL of the assembly. For more information, see Security Requirements to Run Office Solutions.
To grant full trust to the assembly:
- On the end user computer, click Start, point to All Programs, point to Accessories, and then click Command Prompt.
- Type the following command to create a new code group that grants full trust to the assembly.
%windir%\Microsoft.NET\Framework\v2.0.50727\caspol -u -ag All_Code -url " <full assembly path> " FullTrust -n " <name> "
Replace <full assembly path> with the full path of the assembly on the end user computer—for example, C:\DeploymentFolder\WordDocument1.dll.
The -n parameter specifies a name for the new code group. This parameter is not required, but specifying a label makes it easier to later identify and remove the new code group after you have completed this Quick Start. - Click Yes when prompted to confirm that you want to perform the operation, and press ENTER.
- Open the deployed document and verify that the message box appears.
Next Steps
There are many other ways to deploy Visual Studio 2005 Tools for Office solutions, such as deploying the document and assembly to a remote computer or using a deployment manifest to enable automatic assembly updates. Refer to the following topics in the Visual Studio 2005 Tools for Office documentation more detailed information about deploying solutions.
For more information about deployment models for for Word and Excel solutions, see:
For more information about security in Visual Studio 2005 Tools for Office solutions, see:
-- McLean Schofield
-----
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm.
Comments
Anonymous
October 26, 2005
These tutorials are great, but how about something that speaks to Outlook? It's somewhat different as it's not really a document we're putting out.Anonymous
July 17, 2006
PingBack from http://timseal.wordpress.com/2006/07/17/links-for-2006-07-18/Anonymous
November 28, 2006
PingBack from http://www.kintespace.com/rasxlog/?p=503Anonymous
October 06, 2007
hese tutorials are great, but how about something that speaks to Outlook?Anonymous
May 31, 2009
PingBack from http://indoorgrillsrecipes.info/story.php?id=4821