1

I have an WPF Solution with 1 project inside, everything works fine in debug & release mode inside VS2019. But I can't run dotnet publish inside the project,

I have the following errors :

error CS1558: 'App' does not have a suitable static 'Main' method [C:\Users\Alpha\Alpha\Alpha.csproj]
C:\Users\Alpha\Alpha\Dialogs\Views\DialogAddTestView.xaml.cs(25,13): error CS0103: The name 'InitializeComponent' does not exist in the current context [C:\Users\Alpha\Alpha\Alpha.csproj]

and many more InitializeComponent errors

I really can't figure out why,

I checked the project configuration and made sure that the build action of App.xaml is ApplicationDefinition.

(I have tried all the solutions found here Does not contain a static 'main' method suitable for an entry point)

Thanks for your help

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 01 '21 at 11:49
  • I have the exact same problem. VS2019, I build for .Net Framework 4.8. WPF User Control Library is my project (there is no App.xml). It is referenced by another project which is a Windows Executable. The whole thing works in the IDE, but `dotnet publish` gives your 'InitializeComponent' error. Are these your settings ? – angelo.mastro Jan 26 '22 at 11:48
  • I am still stuck with this error... But I have only a single app inside my project, building for .NET 4.7.2 with my app selected as the startup app. – Terspychore Jan 28 '22 at 07:43
  • Is your WPF application a .NET Framework or .NET Core application? If it is .NET Framework application then you should use corresponding msbuild to publish it. – Dragon May 25 '23 at 14:37

0 Answers0