Assembly.Location Property
.NET Framework 1.1
Gets the physical location, in codebase format, of the loaded file that contains the manifest.
[Visual Basic] 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;
Property Value
The location of the loaded file that contains the manifest. If the loaded file was shadow-copied, the Location is that of the file after being shadow-copied. If the assembly is loaded from a byte array, such as when using the Load(Byte[]) method, Location is an empty string ("").
Exceptions
| Exception Type | Condition |
|---|---|
| SecurityException | The caller does not have the required permission. |
Example
The following example displays the location of the loaded file that contains the manifest.
[Visual Basic] 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);
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
- FileIOPermission for access to the path. Associated enumeration: FileIOPermissionAccess.PathDiscovery.
See Also
Assembly Class | Assembly Members | System.Reflection Namespace