I am getting the name of an assembly as follows:
String fullName = Assembly.GetAssembly(typeof(CP.Proj.ILogger)).FullName;
And I get the following:
CP.Proj, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Is there a way to get only the assembly name "CP.Proj"
, without the version and other infos?
You need to get the AssemblyName object of that assembly through the Assembly.GetName() method
Assembly.GetAssembly(typeof(CP.Proj.ILogger)).GetName().Name
If the assembly is the one which is calling that method you can use:
string name = Assembly.GetCallingAssembly().GetName().Name;
or even create an utility method
public static string GetAssemblyShortName()
{
return Assembly.GetCallingAssembly().GetName().Name;
}