Search code examples
c#wpfwaf-framework-c#

Waf Application already defines some members (initializecomponent, main, _contentLoaded)


I'm using the WAF-Framework for building a MVVM-Application. I got my own App-Class (App.xaml and App.xaml.cs).

Everytime I try to compile my application I get 3 different error messages:

  1. The type MyApplication.Presentation.App already defines a member InitializeComponent with same types of parameters
  2. The type MyApplication.Presentation.App already defines a member Main with same types of parameters
  3. The type MyApplication.Presentation.App already contains a definition for _contentLoaded

When I click on the error-message I get redirected to a file called App.g.cs. If I then remove everything within this file, my application will be build and everthings works as wished. But after another change the file is back and I would have to delete it again.

I checked all my files and I can't find another definition of these 3 members. I don't have another Main-Method anywhere. I also tried to rename my Application but this didn't solve the problem.

Any suggestions what I could do to solve this annoying problem?


Solution

  • I had something very similar recently, and it turned out that when importing existing code files I had imported the obj directory itself! screen shot of visual studio

    This directory contained, for example, the auto-generated (and automatically imported) MainWindow.g.i.cs file. So I was effectively including the same partial class definition twice, hence the "already defined" errors.

    Excluding this folder from the project and rebuilding the solution works to resolve the errors.