kmnoe
Topic Author
Posts: 4
Joined: 22 Feb 2021, 03:36

Building first app: Error - Partial declarations of App must not specify different base classes

23 Feb 2021, 03:31

I am creating a new app (first time) in WPF using C# in Visual Studio 2019. I want to use the Noesis ApplicationFramework, so I started looking at the ApplicationGallery project to understand and take pieces from it and put into my app.

So far:
I have created a blank UWP application in VS2019
Added file App.cs to my project and copied the Noesis project's App.cs contents
Cleared the App.xaml file to match Noesis App.xaml file
Confirmed that the class App is extending NoesisApp.Application
Confirmed the installed packages match the ones in Noesis project

I'm running into the following issues:
1) The compiler complains that the partial declarations of 'App' must not specify different base classes. As mentioned above, I checked this in App.cs and App.xaml.cs, they are fine. Am I missing the partial App class elsewhere? I don't see any other partial declaration of App in the project.
2) In the App.xaml, the designer links the <Application> element to Windows.UI>Xaml.Application instead of NoesisApp.Appliation. How can I fix that?

Hoping to get some pointers to get me going.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Building first app: Error - Partial declarations of App must not specify different base classes

23 Feb 2021, 10:57

Did you have a using Windows.UI.Xaml; in your App.cs or in App.xaml.cs? You should define using NoesisApp; instead.

App.cs
using System;
using NoesisApp;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;

namespace RssReader
{
    partial class App : Application
    {
        protected override Display CreateDisplay() { return new WinRTDisplay(); }
        protected override RenderContext CreateRenderContext() { return new RenderContextD3D11(); }

        static void Main()
        {
            CoreApplication.Run(new FrameworkViewSource());
        }

        public class FrameworkViewSource : IFrameworkViewSource
        {
            public IFrameworkView CreateView() { return new FrameworkView(); }
        }

        public class FrameworkView : IFrameworkView
        {
            public void SetWindow(CoreWindow window) { }
            public void Load(string entryPoint) { }
            public void Uninitialize() { }
            public void Initialize(CoreApplicationView applicationView) { }

            public void Run()
            {
                App app = new App();
                app.Uri = "App.xaml";
                app.Run();
            }
        }
    }
}
And verify you have NOESIS symbol defined in your "Conditional compilation symbols" on project Build settings if you are using #if blocks in App.xaml.cs:
#if NOESIS
using Noesis;
using NoesisApp;
#else
using System;
using System.Windows;
#endif

namespace RssReader
{
    public partial class App : Application { }
}
 
kmnoe
Topic Author
Posts: 4
Joined: 22 Feb 2021, 03:36

Re: Building first app: Error - Partial declarations of App must not specify different base classes

23 Feb 2021, 21:20

Hi sfernandez, both the files match what you have mentioned. I'm not using the NOESIS conditional compilation symbol, so I'm assuming, I don't need to put in the #if blocks.

App.cs
using Noesis;
using NoesisApp;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;

namespace UserConsole
{
    partial class App : Application
    {
        protected override Display CreateDisplay()
        {
            return new WinRTDisplay();
        }

        protected override RenderContext CreateRenderContext()
        {
            return new RenderContextD3D11();
        }

        static void Main()
        {
            CoreApplication.Run(new FrameworkViewSource());
        }

        public class FrameworkViewSource : IFrameworkViewSource
        {
            public IFrameworkView CreateView()
            {
                return new FrameworkView();
            }
        }

        public class FrameworkView : IFrameworkView
        {
            public void SetWindow(CoreWindow window) { }
            public void Load(string entryPoint) { }
            public void Uninitialize() { }
            public void Initialize(CoreApplicationView applicationView) { }

            public void Run()
            {
                App app = new App();
                app.Uri = "App.xaml";
                app.Run();
            }
        }
    }
}
App.xaml.cs
using Noesis;
using NoesisApp;

namespace UserConsole
{
    /// <summary>
    /// Provides application-specific behavior to supplement the default Application class.
    /// </summary>
    public partial class App : Application
    {
    }
}
App.xaml
<Application
    x:Class="UserConsole.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UserConsole">
</Application>
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Building first app: Error - Partial declarations of App must not specify different base classes

24 Feb 2021, 11:40

What 'Build Action' do you have for App.xaml and MainPage.xaml? They should be configured as "Embedded Resource" without any 'Custom Build' set.

You also need to specify the StartupUri in your App.xaml pointing to your main window xaml:
<Application
    x:Class="UserConsole.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:UserConsole"
    StartupUri="MainPage.xaml">
</Application>
I attached a minimal project ready to use for you.

Anyway, we are working on some templates for Visual Studio to generate projects using Noesis C# SDK.
Attachments
UserConsole.zip
(23.57 KiB) Downloaded 93 times
 
kmnoe
Topic Author
Posts: 4
Joined: 22 Feb 2021, 03:36

Re: Building first app: Error - Partial declarations of App must not specify different base classes

24 Feb 2021, 17:25

Thank you sfernandez. I will check out the project and respond shortly. Appreciate your help.
 
kmnoe
Topic Author
Posts: 4
Joined: 22 Feb 2021, 03:36

Re: Building first app: Error - Partial declarations of App must not specify different base classes

24 Feb 2021, 23:58

sfernandez, I was able to install your project and get it working. Thank you so much, my first hurdles are gone! Time to start diving into the Noesis GUI components.

Thanks again.

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests