3

When I open help file from my Windows Forms application I'm using this code.

    public static void ShowHelp(string constant)
    {
        Help.ShowHelp(dummyFormForHelp.Value, CHMFile, HelpNavigator.Topic, constant);
    }

It works fine except when I click on GO>URL... or Print button in the help file. [1]

I get no messages and the app and chm file don't response at all. And I need go to task manager and kill the process. I have no idea what it is.

I tried to open the same file using the same code from the simple Windows Form application with only one form and everything was perfect. So I think something wrong in my application.

What can cause such issue? It's a big enterprise application with a lot of screens.

9
  • does it work when you open the CHM file from shell (windows file explorer) and Go > URL? what are you passing as the parent (first argument to ShowHelp(...)? the entire host form, or a particular control? Aug 10, 2017 at 12:47
  • @dlatikay I tried to add null, new Form() and main window and always get the same result. If I open chm file outside of the app everything just fine. Aug 10, 2017 at 13:03
  • Have you tried to (carefully) delete the hh.dat file described at .chm file is not programmatically accessible in SOME Folders? Aug 10, 2017 at 13:54
  • Is this your own CHM file and created by yourself? Aug 10, 2017 at 14:24
  • @help-info.de Yep, it's created from docx file. Aug 10, 2017 at 16:29

3 Answers 3

3

The code snippet for opening the CHM seems not to be clean (??? dummyFormForHelp.Value, constant). Help.ShowHelp() is like a wrapper around the good old HTMLHelp API calls (see also: HTMLHelp API - VBA, VB6 und VB2003). The parameters are a bit stubborn.

A second thought - please read the HTMLHelp API - HH_CLOSE ALL Note and crosscheck your code. Because of a bug in the HH API make sure you call this in your main form's Query_Unload event not OnClose.

Please call the Help.ShowHelp() function with the correct parameters as shown below.

Help.ShowHelp(this, CHMFile, HelpNavigator.Topic, "foobar.htm");

enter image description here

From my example app screenshot above all of the following code is working for me. Please try for your needs. Open URL is special here and not the one shown in your screenshot (URL ...).

#region mnuHelp ---------------------------------------------

private void mnuHelpContents_Click(object sender, EventArgs e)
{
    //--- Show contents of help file.
    Help.ShowHelp(this, helpProviderMain.HelpNamespace);
}

private void mnuHelpIndex_Click(object sender, EventArgs e)
{
    //--- Show index of help file.
    Help.ShowHelpIndex(this, helpProviderMain.HelpNamespace);
}

private void mnuHelpSearch_Click(object sender, EventArgs e)
{
    //--- Show search tab of help file.
    Help.ShowHelp(this, helpProviderMain.HelpNamespace, HelpNavigator.Find);
}

private void mnuHelpTest_Click(object sender, EventArgs e)
{
    //--- Show a web site with help content.
    Help.ShowHelp(this, "http://www.stackoverflow.com");
}

private void mnuHelpOpenTopicByName_Click(object sender, EventArgs e)
{
    //--- Open topic by name.
    Help.ShowHelp(this, helpProviderMain.HelpNamespace, HelpNavigator.Topic, "Garden/tree.htm");
}

private void mnuHelpOpenTopicById_Click(object sender, EventArgs e)
{
    //--- Open topic by ID.
    Help.ShowHelp(this, helpProviderMain.HelpNamespace, HelpNavigator.TopicId, "20010");
}

#endregion -----------------------------------------------

Edit:

Download and run MJ's Diagnostics tool.

MJ's Diagnostics is a small utility that reports if all the HTML Help runtime & Workshop (compiler) DLLs are installed and registered to the correct locations. If you have compiler crashes, and crashes when simply opening a CHM, or when searching from the CHM search tab, then this utility will help sort out rouge DLL problems.

1
  • Unfortunately it does not help, the issue is not to open chm file (which is done correctly), but why application is frozen when some actions are executed in chm (e.g. type anything in search)
    – Serge P
    Aug 16, 2017 at 22:43
2

First of all question is not quite clear described:

  • It should be mentioned that chm file is generated by NuHelp (it was temporary solution but we all know temporary is always permanent, huh?) )
  • dummyFormForHelp.Value says nothing here, it is just lazy initialized instance of form to prevent topmost position of help window and allow to switch between application and help

dummyFormForHelp.Value means:

private static readonly Lazy<Form> dummyFormForHelp = new Lazy<Form>(() =>
{
    var form = new Form();
    form.CreateControl();
    return form;
});

Back to original issues with WinForms<>CHM Help:

  • issues are appeared only if help is opened by application, if help is opened directly - no issues at all
  • endless loop is caught in 100% when navigating to URL, Print or typing any world in Search tab

Research shows that your issue with frozen application and opened chm is not unique:

Solution

Ways of resolving issue:

  • Try the last version of NuHelp
  • Try different converters and check if it can help
  • Do not use any converter and generate help file on your own
  • Start help as different process

Start help as different process:

hh is added to windows path, so such commands can be executed easily:

hh "help.chm::/topic.html"

hh "help.chm::/topic.html#subtopic"

hh -mapid 12345 help.chm

Drawback of workaround: each call of help from application will open new instance of help.

EDIT: 28/08/2017

For future readers:

  • recompilation by different commonly used converters did not help
  • help was recreated with Help&Manual,
  • Index was returned and keywords were configured properly, Search was returned
  • calling of hh was used

Now help works as expected.

2
  • P.S. It is funny to give an answer to co-worker on stackoveflow :-)
    – Serge P
    Aug 16, 2017 at 22:34
  • First of all question is not quite clear described - agreed. Aug 17, 2017 at 6:01
1

This is a bug of Windows 10, and has been fixed in Windows 10, v1607/build 14393.

It was present at least in Windows 10, v1507/build 10240 and v1511/build 10586. (I had created a Connect issue for this topic, but unfortunately, the site is not accessible anymore.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.