次の方法で共有


Assembly.Location プロパティ

マニフェストを格納している読み込み済みファイルの物理的な位置をコードベース書式で取得します。

Public Overridable ReadOnly Property Location As String
[C#]
public virtual string Location {get;}
[C++]
public: __property virtual String* get_Location();
[JScript]
public function get Location() : String;

プロパティ値

マニフェストを格納している読み込み済みファイルの場所。読み込み済みファイルがシャドウ コピーされている場合、 Location はシャドウ コピーされた後のファイルの位置を返します。 Load(Byte[]) メソッドを使用したときなど、アセンブリがバイト配列から読み込まれた場合、Location は空の文字列 ("") になります。

例外

例外の種類 条件
SecurityException 呼び出し元に、必要なアクセス許可がありません。

使用例

マニフェストを格納している読み込み済みファイルの場所を表示する例を次に示します。

 
Dim SampleAssembly As [Assembly]
' Instantiate a target object.
Dim Integer1 As New Int32()
Dim Type1 As Type
' Set the Type instance to the target class type.
Type1 = Integer1.GetType()
' Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = [Assembly].GetAssembly(Integer1.GetType())
' Display the physical location of the assembly containing the manifest.
Console.WriteLine(("Location=" + SampleAssembly.Location))
        End Sub 'Snippet3

[C#] 
Assembly SampleAssembly;
// Instantiate a target object.
Int32 Integer1 = new Int32();
Type Type1;
// Set the Type instance to the target class type.
Type1 = Integer1.GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = Assembly.GetAssembly(Integer1.GetType());
// Display the physical location of the assembly containing the manifest.
Console.WriteLine("Location=" + SampleAssembly.Location);

[C++] 
Assembly* SampleAssembly;
// Instantiate a target object.
Int32 Integer1(0);
Type* Type1;
// Set the Type instance to the target class type.
Type1 = __box(Integer1)->GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = Assembly::GetAssembly(__box(Integer1)->GetType());
// Display the physical location of the assembly containing the manifest.
Console::WriteLine(S"Location= {0}", SampleAssembly->Location);

[JScript] 
var SampleAssembly : Assembly;
// Instantiate a target object.
var Integer1 : Int32 = 0;
var Type1 : Type;
// Set the Type instance to the target class type.
Type1 = Integer1.GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = Assembly.GetAssembly(Integer1.GetType());
// Display the physical location of the assembly containing the manifest.
Console.WriteLine("Location=" + SampleAssembly.Location);

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

Assembly クラス | Assembly メンバ | System.Reflection 名前空間