共用方式為


Assembly 項目 (IntelliSense 程式碼片段)

指定程式碼片段參考的組件名稱。

<Assembly>
    AssemblyName
</Assembly>

屬性和項目

下列各節將說明屬性、子項目和父項目。

屬性

無。

子項目

無。

父項目

項目

描述

Reference

包含程式碼片段所需之組件參考的資訊。

文字值

需要文字值。

此文字會指定程式碼片段參考的組件。

備註

只有在 Visual Basic 程式碼片段中才支援 Assembly 項目。

Assembly 項目的文字值有兩種,即組件的易記文字名稱,例如 System.dll,或是組件的強式名稱 (Strong Name),例如 System,Version=1.0.0.1,Culture=neutral,PublicKeyToken=9b35aa323c18d4fb1。

範例

下列程式碼片段會參考 System.Data.dll 組件。 當插入程式碼片段時,此參考將會加入專案中。

<CodeSnippets xmlns="https://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>Create a data adapter</Title>
            <Description>Creates a SqlDataAdapter object.</Description>
            <Author>Microsoft Corporation</Author>
            <Shortcut>createadapter</Shortcut>
        </Header>
        <Snippet>
            <References>
                <Reference>
                    <Assembly>System.Data.dll</Assembly>
                    <Url>https://www.microsoft.com</Url>
                </Reference>
            </References>
            <Imports>
                <Import>
                    <Namespace>System.Data</Namespace>
                </Import>
            </Imports>
            <Declarations>
                <Literal>
                    <ID>SQL</ID>
                    <ToolTip>Replace with a SQL connection string.</ToolTip>
                    <Default>"SQL connection string"</Default>
                </Literal>
                <Object>
                    <ID>Connection</ID>
                    <Type>System.Data.SqlClient.SqlConnection</Type>
                    <ToolTip>Replace with a connection object in your application.</ToolTip>
                    <Default>dcConnection</Default>
                </Object>
            </Declarations>
            <Code Language="VB">
                <![CDATA[
                    daCustomers = new SqlClient.SqlDataAdapter();
                    selectCommand = new SqlClient.SqlCommand($SQL$);
                    daCustomers.SelectCommand = selectCommand;
                    daCustomers.SelectCommand.Connection = $Connection$;
                ]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

請參閱

概念

程式碼片段結構描述參考