Currently I develop an app in C # (business layer) where I need to get in a variable of type string, the namespace of the function that is running.
This I get in the following way;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test28
{
class Program
{
static void Main(string[] args)
{
string NameSpace = System.Reflection.Assembly.GetExecutingAssembly().EntryPoint.DeclaringType.Namespace;
}
}
This works well, when executed within a project of type aplicacon console .Net Framework
It also works if I create a separate class in the same project, and I use the same method to get the namespace.
The problem is when I want to get the namespace in a project of the .Net Framework class library type.
If the code is executed there, I get the following error:
**
Reference to object not established as an instance of an object.
**
Does anyone know what instruction should be used to get the namespace name in a library of .Net Framework classes?