Search code examples
c#winformschm

Chm file freeze the application when Url or Print buttons were clicked


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.


Solution

  • 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.