I have the following code:
namespace WpfApplication2
{
///
/// Interaction logic for MainWindow.xaml
///
public p
You have two primary options to implement on start activities:
File App.xaml
<Application x:Class="CSharpWPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
Startup="Application_Startup">
Define Startup="Application_Startup"
and handle in file App.xaml.cs:
private void Application_Startup(object sender, StartupEventArgs e)
{
// On start stuff here
}
File App.xaml.cs
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
// On start stuff here
base.OnStartup(e);
// Or here, where you find it more appropriate
}
}
In order to solve this error, don't change the name of the .cs file when creating new code.
If you want a new name for your .cs file then you have to delete everything in the folder where your project is i.e., the fragments of files (bin, obj folders, etc.).