Udostępnij za pośrednictwem


Properties in Visual Studio Tools for Office Projects

There are several important properties that are available in Visual Studio Tools for Office projects. These properties can be accessed in the Properties window.

Properties for Document-Level and Application-Level Projects

The following properties are available to both document-level and application-level projects in Visual Studio Tools for Office.

Namespace for Host Item

The Namespace for Host Item property is only available for Visual C# projects. It appears in the Properties window when you select the document node in a document-level project (such as ExcelWorkbook1.xlsx or WordDocument1.docx) or the application node in an application-level project (such as Excel or Word) in Solution Explorer.

When you create a project using Visual C#, host items are given a namespace based on the name of the project. It is recommended that you not change this namespace by editing the code file directly. Use this property to change the namespace. When you use this property, the namespace is changed in the generated (hidden) code, as well as in the visible code file.

To change the namespace for the host item, set the name in the Namespace for Host Item property.

Trust Assemblies Location

The Trust Assemblies Location property is only available in Microsoft Office 2003 projects. This property appears in the Properties window when you select the project node in Solution Explorer.

This property takes a Boolean value:

  • Select True to update your security policy automatically with full trust permissions on the main project assembly and execution permission on assemblies in the \bin folder and its subfolders. These permissions are checked and granted with every build of the project.

  • Select False to prevent permissions from being granted automatically. If you built the project previously with Trust Assemblies Location set to True, all code groups that were generated for you are removed when you build again with the property set to False. Your project will not run unless you grant permissions to your code manually.

For more information about security in Microsoft Office 2003 projects, see Security in Office Solutions (2003 System).

Note

The Trust Assemblies Location property is not available in projects for the 2007 Microsoft Office system because these projects use a different security model. For more information, see Security in Office Solutions (2007 System).

Properties for Document-Level Projects

The following properties are available only to document-level projects in Visual Studio Tools for Office.

CacheInDocument

The CacheInDocument property appears in the Properties window when you select an instance of a DataSet in the Visual Studio designer. Only public members can be cached; ensure that the Modifiers property is set to Public if you want to cache a DataSet.

This property takes a Boolean value:

  • Select true to cache the dataset in the document.

  • Select false if you do not want the dataset to be cached in the document.

For more information about caching data, see Caching Data and Data in Document-Level Customizations.

Value2

The Value2 property is only available for Excel workbook or template projects. It appears under the Databindings property node in the Properties window when you select a NamedRange control on the worksheet designer.

Use the Value2 property in the Properties window to bind the Value2 property of the NamedRange to a field in your data source.

See Also

Concepts

Creating Office Solutions in Visual Studio

Visual Studio Tools for Office Project Templates Overview

Visual Studio Tools for Office Project Events