For .NET Core assemblies, and for .NET Framework assemblies that aren't in the global assembly cache, you can get the fully qualified assembly name in a number of ways:
You can use code to output the information to the console or to a variable, or you can use the Ildasm.exe (IL Disassembler) to examine the assembly's metadata, which contains the fully qualified name.
If the assembly is already loaded by the application, you can retrieve the value of the Assembly.FullName property to get the fully qualified name. You can use the Assembly property of a Type defined in that assembly to retrieve a reference to the Assembly object. The example provides an illustration.
If you know the assembly's file system path, you can call the static (C#) or Shared (Visual Basic) AssemblyName.GetAssemblyName method to get the fully qualified assembly name. The following is a simple example.
C#
using System;
using System.Reflection;
publicclassExample
{
publicstaticvoidMain()
{
Console.WriteLine(AssemblyName.GetAssemblyName(@".\UtilityLibrary.dll"));
}
}
// The example displays output like the following:// UtilityLibrary, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null
Imports System.Reflection
Public Module Example
Public Sub Main
Console.WriteLine(AssemblyName.GetAssemblyName(".\UtilityLibrary.dll"))
End Sub
End Module
' The example displays output like the following:
' UtilityLibrary, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null
You can use the Ildasm.exe (IL Disassembler) to examine the assembly's metadata, which contains the fully qualified name.
The following example shows how to display the fully qualified name of an assembly containing a specified class to the console. It uses the Type.Assembly property to retrieve a reference to an assembly from a type that's defined in that assembly.
#using <System.dll>
#using <System.Data.dll>
using namespace System;
using namespace System::Reflection;
ref class asmname
{
public:
static void Main()
{
Type^ t = System::Data::DataSet::typeid;
String^ s = t->Assembly->FullName->ToString();
Console::WriteLine("The fully qualified assembly name " +
"containing the specified class is {0}.", s);
}
};
int main()
{
asmname::Main();
}
C#
using System;
using System.Reflection;
classasmname
{
publicstaticvoidMain()
{
Type t = typeof(System.Data.DataSet);
string s = t.Assembly.FullName.ToString();
Console.WriteLine("The fully qualified assembly name " +
"containing the specified class is {0}.", s);
}
}
Imports System.Reflection
Class asmname
Public Shared Sub Main()
Dim t As Type = GetType(System.Data.DataSet)
Dim s As String = t.Assembly.FullName.ToString()
Console.WriteLine("The fully qualified assembly name " +
"containing the specified class is {0}.", s)
End Sub
End Class
Izvor za ovaj sadržaj možete pronaći na GitHubu, gdje možete stvarati i pregledavati probleme i zahtjeve za povlačenjem. Dodatne informacije potražite u našem vodiču za suradnike.
Povratne informacije o proizvodu .NET
.NET je projekt otvorenog koda. Odaberite vezu za slanje povratnih informacija:
Pridružite se seriji susreta kako biste s kolegama programerima i stručnjacima izgradili skalabilna rješenja umjetne inteligencije temeljena na stvarnim slučajevima upotrebe.