1

I am following this tutorial here: https://prismlibrary.com/docs/wpf/getting-started.html

It first modifies the class used in App.xaml as follows:

<prism:PrismApplication
    x:Class="WpfApp1.App"
    ...
    xmlns:prism="http://prismlibrary.com/">
...
</prism:PrismApplication>

Then, in the App.xaml.cs code-behind file, it derives the App class from class PrismApplication (replacing the standard WPF Application class) like so:

public partial class App : PrismApplication
...

When I replicated the above steps, I got the following error:

CS0263 Partial declaration of 'App' must not specify different base classes

Looking up the error, I came across the following answer: https://stackoverflow.com/a/40616616/ which says that you need only specify the base class in one of the partial class declaration files, and that usually, the specification in the code-behind file is unnecessary.

Accordingly, I changed the partial class definition in the code-behind file as follows:

public partial class App 

And sure enough, the error went away.

My question: Since PrismApplication is obviously not the correct way to specify the base class name in the code-behind file for the above case (corresponding to prism:PrismApplication), what is?

Thanks in advance.

Sabuncu
  • 5,095
  • 5
  • 55
  • 89
  • 1
    There's more than one `PrismApplication` - one for each container, i.e. one in `Prism.DryIoc`, one in `Prism.Unity`... you may want to check the namespaces and/or reference it explicitly in code behind (with full name space). – Haukinger Oct 27 '22 at 07:28

1 Answers1

3

Official samples do explicit inheritance from base class in .xaml.cs like this. Try deleting bin and obj folders of your project as suggested here, it might resolve the issue.

Sabuncu
  • 5,095
  • 5
  • 55
  • 89
Muhammad Sulaiman
  • 2,399
  • 4
  • 14
  • 28