Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3406422
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:37:33+00:00 2026-05-18T05:37:33+00:00

I have a simple program. Its job is to move files from A to

  • 0

I have a simple program. Its job is to move files from A to B (a glorified bat file honestly).

The problem I’m having is that it crashes… at the end.

App.xaml.cs:

<Application x:Class="app.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:properties="clr-namespace:app.Properties" 
             StartupUri="Views\MainWindow.xaml">
    <Application.Resources>
        <properties:Settings x:Key="Settings" />
    </Application.Resources>
</Application>

App.CS:

using System.ComponentModel;
using System.Linq;
using System.Windows;
using app.Model;
using app.Properties;
using app.Views;

namespace app
{
    public partial class App
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            string xmlDoc = Settings.Default.Config;
            var parms = new MoveFilesParams(xmlDoc);
            Process.MoveFiles(parms);
        }
    }
}

Simple body. Assuming I pass it no command line parameter, it’s supposed to just run automatically. With parameters, it will run the WPF.

It pulls settings from the xmlDoc populated in the Application settings. It then passes those settings via Parms class. Then it either runs, or popu

When run, I’ve tried a try/catch without errors inside the OnStartup – and it errors out after the OnStarup block with a NullReferenceException.

Edit 1: Sorry if I’m not responding fast enough (Yay for impatient people downvoting because they are impatient), but I’ve removed the background worker parts since I’m not using that right now. I’m still getting the same Null error at the end. Updated code here to reflect removal of BackgroundWorker.

Edit 2: Removed the GUI aspect of App.cs (since background worker and gui is secondary atm). So this program, as of right now, simply

  • loads
  • pulls xml location from app.config
  • loads parm class from XmlDoc
  • Moves Files successfully
  • crashes with NullReferenceException was Unhandled error. I can comment out everything and it erros on “finish” of OnStart
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:37:34+00:00Added an answer on May 18, 2026 at 5:37 am

    If your main thread exits before the background task is completed, and if BackgroundWorker creates a background thread (I think it does, but not 100% sure), then when your UI thread exits the background thread would be shut down aggressively.

    Try to keep your main thread running until you are definitely sure that the BackgroundWorker has completed, and see if it still crashes. If it does not, then you found the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Tray icon program that opens a site using System.Diagnostics.Process.Start(URL) And
I have two simple while loops in my program that I feel ought to
I have a relatively simple select statement in a VB6 program that I have
I have a simple program under Linux which sends SIGUSR1 signal to its child
I have a really simple program that checks the date and returns if the
I have a simple script which is used to start another program. This other
Have a look at this very simple example WPF program: <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I have the need to express simple conditionals as program input. The input must
I have simple regex \.*\ for me its says select everything between and ,
I have a daemon that reads a configuration file in order to know where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.