It sounds like an unhandled exception. Try capturing the unhanded exception
try
{
var mainForm= new MainForm();
Application.Run(mainForm);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Unhandled Error", MessageBoxButton.OK, MessageBoxImage.Stop);
}
UPDATE
I don't work with .chm help files and yesterday I did not fire up a test project as I was heading out the door. What I did post was "good proactice" handling of exceptions that are not normally caught. There is also a general thread exception that you should also catch if doing any multithreading programming.
This morning a downloaded a test .chm file and wrote a bit of DotNet (Core) 7.0 code to test how the
ShowHelp
. Here is the sample code used:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string helpPath = Path.Combine(Environment.CurrentDirectory, "PowerCollections.chm");
string helpTopic = "Algorithms";
Help.ShowHelp(this, helpPath , helpTopic);
Debugger.Break();
}
}
The code does not stop when the
ShowHelp
method is called. The
Debugger.Break();
is hit immediately after the help file is shown. Continue running the code and close the help file and the WinForm app is still running. The app itself does not close when the help file is closed.