Null Reference Exception with System.Reflection.Assembly

This is expected especially in the Windows Services where they are loaded by an unmanaged runtime.

Use:

  Process.GetCurrentProcess().MainModule.FileName

To get unmanaged entry point file.


Update

It seems you are looking for this:

  System.Reflection.Assembly.GetExecutingAssembly().GetName().Name

problem is solved guys,

I am using

Assembly.GetAssembly(ex.TargetSite.DeclaringType.UnderlyingSystemType).GetName().Name 

to get the EntryAssemblyName.
In this case I already has parameter which is taking Exception 'ex', so I solved it by using that.

Many Thanks Guys, specially @Aliostad

Cheers