Assembly.GetEntryAssembly Method

Definition

Gets the entry assembly for the running application.

public static System.Reflection.Assembly? GetEntryAssembly ();
public static System.Reflection.Assembly GetEntryAssembly ();

Returns

The entry assembly for the running application. Can return null when called from unmanaged code.

Remarks

.NET Framework only: In the default application domain, this method returns the process executable. In other application domains, this method returns the first executable that was executed by ExecuteAssembly.

The GetEntryAssembly method can return null when a managed assembly has been loaded from an unmanaged application. For example, if an unmanaged application creates an instance of a COM component written in C#, a call to the GetEntryAssembly method from the C# component returns null, because the entry point for the process was unmanaged code rather than a managed assembly.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.5, 1.6, 2.0, 2.1