Building first app: Error - Partial declarations of App must not specify different base classes
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.
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.
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Building first app: Error - Partial declarations of App must not specify different base classes
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
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:
App.cs
Code: Select all
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();
}
}
}
}
Code: Select all
#if NOESIS
using Noesis;
using NoesisApp;
#else
using System;
using System.Windows;
#endif
namespace RssReader
{
public partial class App : Application { }
}
Re: Building first app: Error - Partial declarations of App must not specify different base classes
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
App.xaml.cs
App.xaml
App.cs
Code: Select all
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();
}
}
}
}
Code: Select all
using Noesis;
using NoesisApp;
namespace UserConsole
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : Application
{
}
}
Code: Select all
<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>
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Building first app: Error - Partial declarations of App must not specify different base classes
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:
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.
You also need to specify the StartupUri in your App.xaml pointing to your main window xaml:
Code: Select all
<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>
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
Re: Building first app: Error - Partial declarations of App must not specify different base classes
Thank you sfernandez. I will check out the project and respond shortly. Appreciate your help.
Re: Building first app: Error - Partial declarations of App must not specify different base classes
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.
Thanks again.
Who is online
Users browsing this forum: Ahrefs [Bot] and 74 guests