AssemblyName.GetAssemblyName Method
Gets the AssemblyName for a given file.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- assemblyFile
- Type: System.String
The path for the assembly whose AssemblyName is to be returned.
| Exception | Condition |
|---|---|
| ArgumentNullException | assemblyFile is null. |
| ArgumentException | assemblyFile is invalid, such as an assembly with an invalid culture. |
| FileNotFoundException | assemblyFile is not found. |
| SecurityException | The caller does not have path discovery permission. |
| BadImageFormatException | assemblyFile is not a valid assembly. |
| FileLoadException | An assembly or module was loaded twice with two different sets of evidence. |
The following code example gets the AssemblyName for an assembly on disk. It will not run unless you replace the string "MyAssembly.exe" with the filename of an assembly (including the path, if necessary) on your hard disk. Alternatively, you can compile this code example as "MyAssembly.exe".
using System; using System.Reflection; public class AssemblyName_GetAssemblyName { public static void Main() { // Replace the string "MyAssembly.exe" with the name of an assembly, // including a path if necessary. If you do not have another assembly // to use, you can use whatever name you give to this assembly. // AssemblyName myAssemblyName = AssemblyName.GetAssemblyName("MyAssembly.exe"); Console.WriteLine("\nDisplaying assembly information:\n"); Console.WriteLine(myAssemblyName.ToString()); } }
- FileIOPermission
for access to information in the path. Associated enumeration: FileIOPermissionAccess.PathDiscovery.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.