I’ve written some VB.NET DLLs which are referenced both from a VB.NET Windows service and from an ASP.NET project. The DLLs have some custom logging functions built in.
I’d like to be able to determine, from the DLL code, whether the logging function is being called from the Windows service or the ASP.NET project, so I can perform appropriate logging tasks.
Any tips on how I can work it out?
Sure, using
System.Reflection.Assembly.GetEntryAssembly()you will find the executable (Assembly) running the current process.I’m unsure on what you will find executing into the ASP.Net process (debug to find out) but with the windows service you will find your service executable. You can check it with the property FullName (or Name)