Reference3.Isolated 属性

定义

获取或设置 COM 引用是否是独立的,即未向 Windows 注册的。Gets or sets whether the COM reference is isolated, that is, not registered with Windows.

public:
 property bool Isolated { bool get(); void set(bool value); };
public:
 property bool Isolated { bool get(); void set(bool value); };
[System.Runtime.InteropServices.DispId(122)]
[get: System.Runtime.InteropServices.DispId(122)]
[set: System.Runtime.InteropServices.DispId(122)]
public bool Isolated { get; set; }
[<System.Runtime.InteropServices.DispId(122)>]
[<get: System.Runtime.InteropServices.DispId(122)>]
[<set: System.Runtime.InteropServices.DispId(122)>]
member this.Isolated : bool with get, set
Public Property Isolated As Boolean

属性值

Boolean

一个布尔值,指示引用是否是独立的。A boolean value indicating whether the reference is isolated.

属性

示例

此示例将 COM 引用添加到打开的 Visual BasicVisual BasicVisual C#Visual C# 项目中,并显示其 Isolated 属性。This example adds a COM reference to an open Visual BasicVisual Basic or Visual C#Visual C# project and displays its Isolated property. 若要将此示例作为外接程序运行,请参阅 如何:编译和运行自动化对象模型代码示例To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

添加的引用 (spcommon.dll) 的默认路径为: <installation root> \Program Files\Common Files\SpeechEngines\Microsoft。The default paths for the reference added (spcommon.dll) is: <installation root> \Program Files\Common Files\SpeechEngines\Microsoft. <file path>将此示例中的替换为此或其他相应的文件路径。Replace <file path> in the example with this or another appropriate file path.

Imports VSLangProj  
Imports VSLangProj2  
Imports VSLangProj80  
Public Sub OnConnection(ByVal application As Object,_  
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _  
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection  
    applicationObject = CType(application, DTE2)  
    addInInstance = CType(addInInst, AddIn)  
    GetIsolatedValue(applicationObject)  
End Sub  
Sub GetIsolatedValue(ByVal dte As DTE2)  
    Dim aProject As Project  
    Dim aVSProject As VSProject2  
    aProject = applicationObject.Solution.Projects.Item(1)  
        aVSProject = _  
CType(applicationObject.Solution.Projects.Item(1).Object, VSProject2)  
    ' Add an Assembly reference and display its identity.  
    Dim newRef As Reference3  
    ' Add a COM reference and display its isolation value.  
    ' Replace the <file path> with an actual file path.  
    newRef = CType(aVSProject.References.Add_  
("<file path>\spcommon.dll"), Reference3)  
    MsgBox("Added a COM reference, named: " & newRef.Name)  
    MsgBox("The Isolated value of " & newRef.Name & " is "   
    & newRef.Isolated.ToString())  
End Sub  
using System.Windows.Forms;  
using VSLangProj;  
using VSLangProj2;  
using VSLangProj80;  
public void OnConnection(object application,  
 ext_ConnectMode connectMode, object addInInst, ref Array custom)  
{  
    applicationObject = (DTE2)application;  
    addInInstance = (AddIn)addInInst;  
    GetIsolatedValue(((DTE2)applicationObject));  
}  
public void GetIsolatedValue(DTE2 dte)  
{  
    // The first project is a Visual Basic or C# project.  
    VSProject2 vsProject =   
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));  
    Reference3 aRef = null;  
    // Add a COM reference and display its isolated value.  
    // Replace <file path> with an actual file path.  
    aRef = (Reference3)vsProject.References.Add  
((@"<file path>\spcommon.dll"));  
    MessageBox.Show("Added a COM reference, named: " + aRef.Name);  
    MessageBox.Show("The isolated value of " + aRef.Name + " is "   
+ aRef.Isolated.ToString());  
}  

适用于