DEV Community

Cristian Sifuentes
Cristian Sifuentes

Posted on

Program does not contain a static 'Main' method suitable for an entry point β€” Entry Points in .NET 6+ and Azure Calling SDK

Program does not contain a static Main

🚨 Program does not contain a static 'Main' method suitable for an entry point β€” Entry Points in .NET 6+ and Azure Calling SDK

In the evolving landscape of .NET development, transitioning to modern SDKs like .NET 6 and beyond often exposes developers to changes in application bootstrapping β€” especially with Windows-targeted apps using UI frameworks or SDKs like Azure.Communication.Calling.WindowsClient.

One common and confusing error that appears in this context is:

Program does not contain a static 'Main' method suitable for an entry point
Enter fullscreen mode Exit fullscreen mode

In this article, we’ll break down:

  • Why this error occurs in .NET 6 projects
  • How to resolve it in WPF, WinForms, or WindowsClient scenarios
  • What’s different about Azure.Communication.Calling.WindowsClient v1.11.1
  • Best practices for startup configuration

Why This Error Happens in .NET 6+

This error indicates that your .NET runtime is unable to locate the startup entry point for your executable application β€” specifically a static void Main(string[] args) method.

The problem occurs most often in the following situations:

Scenario Root Cause
βœ… OutputType is set to Exe Expects a Main method
❌ No static Main method defined Runtime cannot start
❌ Targeting net6.0-windows with no UI entry Common with non-WPF, WinUI, or Windows Forms
βœ… Using Azure.Communication.Calling.WindowsClient SDK Expects integration with UI loop and WinRT hosting

Example Project File (.csproj)

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Azure.Communication.Calling.WindowsClient" Version="1.11.1" />
  </ItemGroup>
</Project>
Enter fullscreen mode Exit fullscreen mode

What’s Missing?

A UI-based entry point or a Program.Main method. In SDK-style projects like this, you must provide a bootstrapper for your app.


Solution 1: Define a Program.Main Entry Point

using System;
using System.Windows;

internal class Program
{
    [STAThread]
    public static void Main(string[] args)
    {
        var app = new App(); // your App.xaml.cs entry class
        app.InitializeComponent();
        app.Run();
    }
}
Enter fullscreen mode Exit fullscreen mode

This pattern is required when using:

  • βœ… WPF or WinForms app manually bootstrapped
  • βœ… You’re not using App.xaml or project defaults

Solution 2: Use WPF-style App.xaml with <Application> Tag

<Application x:Class="MyApp.App"
             StartupUri="MainWindow.xaml"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</Application>
Enter fullscreen mode Exit fullscreen mode

In this case:

  • App.xaml.cs provides the entry point behind the scenes
  • No need for explicit Main() method
  • Works with Azure.Communication.Calling.WindowsClient since it hosts UI

Why This Matters for Azure.Communication.Calling.WindowsClient

This SDK expects:

  • A Windows application host environment
  • A UI thread context, typically with STAThread set
  • Integrated media handling for devices and calls

πŸ“¦ Version 1.11.1 requires hosting within a WinRT-friendly runtime, which means you must bootstrap a native window environment.

βœ… This is not a headless console SDK β€” you need an actual app container.


Best Practices

Practice Reason
Always define a static Main for WinUI or WPF manually-hosted apps Ensures .NET 6+ runtime compatibility
Use App.xaml if relying on implicit WPF startup Keeps project cleaner and more manageable
Set [STAThread] in Main() Required for Windows UI threading
Avoid using Exe output without valid entry point Ensures app runs correctly

Final Thoughts

Understanding how application entry points are resolved is essential in .NET 6+ development, especially when integrating with SDKs like Azure.Communication.Calling.WindowsClient. This SDK brings powerful calling capabilities β€” but requires the right app container to function properly.

Mastering these patterns ensures your app is bootstrapped correctly, performs reliably, and is future-ready for more Azure communications integrations.


✍️ Written by: Cristian Sifuentes – Full-stack dev crafting scalable apps with [NET - Azure], [Angular - React], Git, SQL & extensions. Clean code, dark themes, atomic commits

πŸ’¬ Have you encountered this error? Share your project setup and let’s solve it together!

Top comments (0)