Reference3.Isolated 属性
获取或设置该 COM 引用是否独立,即没有向 Windows 注册。
命名空间: VSLangProj80
程序集: VSLangProj80(在 VSLangProj80.dll 中)
语法
声明
Property Isolated As Boolean
bool Isolated { get; set; }
property bool Isolated {
bool get ();
void set (bool value);
}
abstract Isolated : bool with get, set
function get Isolated () : boolean
function set Isolated (value : boolean)
属性值
类型:Boolean
一个指示引用是否独立的 boolean 值。
示例
此示例向打开的 Visual Basic 或 Visual C# 项目添加 COM 引用,并显示其 Isolated 属性。 若要将此示例作为外接程序运行,请参见如何:编译和运行自动化对象模型代码示例。
所添加的引用 (spcommon.dll) 的默认路径为:<安装根目录>\Program Files\Common Files\SpeechEngines\Microsoft。 请将示例中的 <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());
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。