Russ Clark
Russ Clark

Reputation: 13440

Why has my function to display a help file (chm) suddenly stopped working?

I have a VSTO add in for Outlook written in C# that has a button to display a chm help file that has been working fine for a couple of years, and suddenly stopped working. When I click the button that runs the following code, nothing happens,

try
{
    string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase), "ema.chm");

    // Show the help.
    Help.ShowHelp(null, path);
}
catch (System.Exception ex)
{
    MessageBox.Show(ex.Message);
} 

Does anyone have any ideas what may cause a problem like that?

Upvotes: 1

Views: 605

Answers (2)

help-info.de
help-info.de

Reputation: 7260

If it's really true nothing changed and working for years hh.dat may cause a error.

The hh.dat file stores user-specific information on all the HTMLHelp files (*.CHM) on your system (position, favourite topics, search history, etc.), and may cause a error if it has somehow been corrupted.

Delete or rename the file hh.dat to reset all (!) CHM windows on your system to their default settings. Windows will create a new version of hh.dat when you next open any .chm file. You should find hh.dat at:

Windows XP: \Documents and Settings\%username%\Application Data\Microsoft\HTML Help

Windows 7: \Users\%username%\AppData\Roaming\Microsoft\HTML Help

Upvotes: 0

Scott Solmer
Scott Solmer

Reputation: 3897

I see two potential problems.

1) The way you are building path is not reliable.
There are many ways to get a path, and they are not all created equal. For example, GetCallingAssembly is susceptible to JIT inlining which may produce varying results.
But I believe the real issue was hinted at by Hans already.
Try using a different way to build your path. For example, this way.

Here is an example of the way I usually get the path of a file in the assembly directory using a property:

    private string myXMLFile()
    {
        string ExecutingPath = AppDomain.CurrentDomain.BaseDirectory;
        return ExecutingPath + "MyFile.XML";
    }

Then it's easy to use it like this:

if (File.Exists(myXMLFile) == false) { CreateNewXMLFile(); }
XDocument Xdoc = XDocument.Load(myXMLFile);
...
Xdoc.Save(myXMLFile);

2) .CHM format may be blocked by Windows for "security" reasons.
It can be unblocked however, which leads to it working on some systems but not on others.
See Windows 8 64bit can't open chm files

Upvotes: 1

Related Questions