This project has moved and is read-only. For the latest updates, please go here.

Script Error in .chm when built with VS2005 style

Topics: User Forum
Sep 12, 2011 at 6:01 AM

I am returning to SHFB after a long absence and never was particularly adept or advanced. My first effort with the current version was to simply rebuild a old and simple project from SHFB version Conversion and build went surprisingly smoothly, including my HTML additional content. I am using the HTML Help 1 help compiler.

However, when built with the VS2005 presentation style, each page of the normal help (not the HTML additional content), reports "An error has occurred in the script on this page".
Details are:
   Line:   133
   Char: 9
   Error: Unable to set value of the property 'display': object is null or undefined
   Code:  0
   URL: mk:@MSITStore:C:\NetLibraries\JDPLibrary\JDPLibrary\Documentation\Help\Help\Documentation.chm::/scripts/CommonUtilities.js

When I rebuild the same (converted) project using Prototype PresentationStyle, all works exactly as expected and there is no error on any page.

My apologies if this is a known problem - I did not find it in the FAQ or other docs.

Jim Parsells

Sep 12, 2011 at 7:18 PM

I don't recall seeing this particular error.  Did you apply the Sandcastle Styles patch as part of the installation process?  If you had any custom build components in the SHFB project, you might try deleting and re-adding them as there were some significant changes made to a few of them between and the current release.  Updating the configurations on any plug-ins wouldn't hurt either if you added any to the project.



Sep 12, 2011 at 8:23 PM

Checking a little deeper, I found that the script error occurs because the is, apparently, no style for F#. The relevant lines are in C:\Program Files (x86)\Sandcastle\Presentation\vs2005\Scripts:

    } else if (devlang == 'vb') {
        sd['span.cs'].display = 'none';
        sd['span.vb'].display = 'inline';
        sd['span.cpp'].display = 'none';
        sd[''].display = 'none';
        sd['span.fs'].display = 'none';     //this is the error line.

Thinking I might have had an older version of Sandcastle or SHFB installed prior to installing with the Wizard, I uninstalled Sandcastle and SHFB and deleted the directories left over from the uninstall.
I also deleted the entire directory where I had downloaded and expanded the most current
I then re-downloaded that file, expanded it, and reinstalled, using the wizard. I installed everything that the wizard offered, though I did not install MS Help 2, since I don't use it. Installation was error free.

Net result of this was exactly the same as before -- PresentationStyle VS2005 builds without error but has script errors when the built pages of the .chm are displayed.
There are no plug-ins, no custom build components, nor anything special about it beyond what the wizard installs. This is a completly fresh install with nothing additional. The only item that is not completely standard is one HTML page that I added as additional content in the original ( project. That page is correctly located in the new project and displays as expected - no error on that one.

A brief look at function getStyleDictionary() (in the same script file) makes me wonder if the devlang == 'vb' branch where the error occurs was ever fully tested - ie if no "fs" stylesheet is present in document.styleSheets, then the error is completely explained. Obviously, there is something going wrong in a more global sense and this error is just the first symptom. Of course there might also be some global flag (which I don't know of) to ignore such errors, then all would also probably be OK since the actual pages where the errors occur display as expected.

If I continue after the first error, I can cause another error by clicking the "Visual Basic" checkbox at the very top of the page (there is no other language choosing checkbox). That error is:
"Unable to get value of property 'ToggleCheckState':object is null or undefined" at
   Line:    401
   Char:   5
   URL:   mk:@MSITStore:C:\NetLibraries\JDPLibrary\JDPLibrary\Documentation\Help\Help\Documentation.chm::/scripts/script_manifold.js

That script portion is:

// called onclick in a devlang filter checkbox
// tasks to perform at this event are:
//   toggle the check state of the checkbox that was clicked
//   update the user's devlang preference, based on devlang checkbox states
//   update stylesheet based on user's devlang preference
//   show/hide snippets/syntax based on user's devlang preference
function SetLanguage(checkbox)
    // toggle the check state of the checkbox that was clicked
    devlangsMenu.ToggleCheckState(;    //line where error occurs
    // update the label of the dropdown menu
    SetDropdownMenuLabel(devlangsMenu, devlangsDropdown);
    // update the display of the document's items that are dependent on the devlang setting

This seems to stem from the same more global problem.

Speculation -- if I just built the project from scratch, would I have the same problem? Don't know because I haven't tried this yet. In other words, is this a problem in the conversion? Seems possible since there was no F# existing when the project was first built.


Sep 13, 2011 at 8:38 PM
Edited Sep 13, 2011 at 8:41 PM

What languages do you have selected in the SyntaxFilters project property?  Does the same thing happen if you go back to the default "Standard" setting.  I do know there's a problem with the generated topics if you set SyntaxFilters to "None" as the XSL transformations will then skip generating parts of the topic and the topic itself become somewhat invalid due to the missing elements.  Choosing at least one language works around that issue.

Another possiblity: Are you replacing the Presentation.css file with one from your project?  If so, it's probably out of date and needs to be updated to include the relevant styles that have been added since the last version you were using.



Sep 13, 2011 at 10:30 PM

My selected language in the SyntaxFilters is VisualBasic.
Adding VisualBasicUsage to the list changes the error a bit, it now errors here:

    } else if (devlang == 'nu') {
        sd['span.cs'].display = 'none';
        sd['span.vb'].display = 'none';
        sd['span.cpp'].display = 'none';
        sd[''].display = 'inline';
        sd['span.fs'].display = 'none';   // error occurs here now

I have not changed Presentation.css - this is a fresh install with no user customization.  Frankly, I have no idea how to replace Presentation.css on a project by project basis.
The HTML page that I include as additional content does reference a .css file which is based on an old version of Presentation.css, with some changes. It, however, is named "modified_Presentation.css", so I don't see how it could be mucking things up.

As a semi-related question: The SHFB docs seem quite adamant that additional content can only be in MAML. As far as I can tell, the conversion quite happily accepted HTML additonal content. I can tell it did not convert to MAML because the display of the one HTML page is obviously using my old "modified_Presentation.css". Is this an "error" in the conversion or is SHFB reasonably happy to accept additional content in HTML? I am curious because, though this is a simple project, most of my old projects have a lot of HTML additional content - as will any future projects.

A possible difference between this project and a "normal" project is that the compile of the source and therefore the XML Targets Framework 2.0 rather than a more recent FW.


Sep 13, 2011 at 11:39 PM
Edited Sep 13, 2011 at 11:41 PM

Have you tried removing modified_Presentation.css from the project to see if that fixes the issue?  It's possible that its content is conflicting some how with the newer stylesheet.  If you create a new project containing nothing but the assembly and XML comments file, do you get the same error?  If not, that would also point to the additional content causing an issue.  The framework version shouldn't make a difference as that only tells MRefBuilder what framework to use when generating the reflection information.

You might try flushing the browser cache too. I suppose it's possible, it's got an old copy of the stylesheet cached.

The old HTML additional content model has been deprecated but is still supported for backward compatibility to a certain extent.  It doesn't work at all with MS Help Viewer output though and won't receive any further updates, additions, or fixes going forward.  The HTML to MAML converter can be used to convert HTML topics to MAML but they'll require some fix-ups hence no auto-conversion of content when converting a SHFB project.  See the help file supplied with the converter for more information on its usage.


Sep 14, 2011 at 5:20 PM

ARRRGH - you're second response solved the problem!!! It was my implementation of that response that caused the difficulties!!!?!!

Indeed, I did find an old Presentation.css in one deep branch of the directory tree. It was in the dir created during the conversion process. I could remove that file all I wanted from the my original directory and that had no effect since the new project was using the copy of that file.

I removed all traces of the new project, ensured that I had no Presentation.css in my original dir tree, re-converted the project, and all was good.

Thanks for your solution and your patience,