Training
Module
Create a .NET Aspire project - Training
Learn how to create cloud-native applications from scratch or add orchestration to an existing app by using the .NET Aspire stack in .NET 8.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note
This article is specific to .NET Framework. It doesn't apply to newer implementations of .NET, including .NET 6 and later versions.
A common language runtime host creates application domains automatically when they are needed. However, you can create your own application domains and load into them those assemblies that you want to manage personally. You can also create application domains from which you execute code.
You create a new application domain using one of the overloaded CreateDomain methods in the System.AppDomain class. You can give the application domain a name and reference it by that name.
The following example creates a new application domain, assigns it the name MyDomain
, and then prints the name of the host domain and the newly created child application domain to the console.
using namespace System;
using namespace System::Reflection;
ref class AppDomain1
{
public:
static void Main()
{
Console::WriteLine("Creating new AppDomain.");
AppDomain^ domain = AppDomain::CreateDomain("MyDomain");
Console::WriteLine("Host domain: " + AppDomain::CurrentDomain->FriendlyName);
Console::WriteLine("child domain: " + domain->FriendlyName);
}
};
int main()
{
AppDomain1::Main();
}
using System;
using System.Reflection;
class AppDomain1
{
public static void Main()
{
Console.WriteLine("Creating new AppDomain.");
AppDomain domain = AppDomain.CreateDomain("MyDomain");
Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
Console.WriteLine("child domain: " + domain.FriendlyName);
}
}
Imports System.Reflection
Class AppDomain1
Public Shared Sub Main()
Console.WriteLine("Creating new AppDomain.")
Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain")
Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName)
Console.WriteLine("child domain: " + domain.FriendlyName)
End Sub
End Class
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Training
Module
Create a .NET Aspire project - Training
Learn how to create cloud-native applications from scratch or add orchestration to an existing app by using the .NET Aspire stack in .NET 8.