Programmatically obtain the name of the assembly

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

How can I programatically obtain the name of the assembly that the code is
executing in ?

I've tried
System.Reflection.Assembly.GetExecutingAssembly().FullName
but this returns something like
"WorkPlace.Presentation.CommonLib, Version=1.0.1496.30348,
Culture=neutral, PublicKeyToken=null"
whereas what I'm after is just the "WorkPlace.Presentation.CommonLib" part.
Of course I could read up to the first comma but I'd like something cleaner.

I need this path to plug into a resource file name that I want to scan which
is embedded into my project :-

// TODO: How can I get the first part of this programmatically?
string ResFile =
string.Format("WorkPlace.Presentation.CommonLib.Messages_{0}",groupID);
ResourceManager rm = new
ResourceManager(ResFile,System.Reflection.Assembly.GetExecutingAssembly().);
ResourceSet rs =
rm.GetResourceSet(System.Threading.Thread.CurrentThread.CurrentUICulture,tru
e,true);
IDictionaryEnumerator id = rs.GetEnumerator();
// etc
 
This should work:
System.Reflection.Assembly.GetExecutingAssembly().GetName().Name
 
I think that you are looking for "Name'' ... Also look up the AssemblyName class in the documentation..
 
How can I programatically obtain the name of the assembly that the code is
executing in ?

I've tried
System.Reflection.Assembly.GetExecutingAssembly().FullName
but this returns something like
"WorkPlace.Presentation.CommonLib, Version=1.0.1496.30348,
Culture=neutral, PublicKeyToken=null"
whereas what I'm after is just the "WorkPlace.Presentation.CommonLib" part.

Instead of the "FullName" property, try the "GetName" method. It
returns an AssemblyName object that should have all of those pieces
already parsed out.
 
* "JezB said:
How can I programatically obtain the name of the assembly that the code is
executing in ?

\\\
MsgBox(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name)
///
 
Back
Top