"Invalid URI: The hostname could not be parsed" in Topic Previewer

Topics: User Forum
Apr 15, 2013 at 1:08 PM
Edited Apr 15, 2013 at 1:09 PM
When a MAML topic file contains an external link with the following kind of URI...
        <externalLink>
          <linkText>source code in the version-control server</linkText>
          <linkUri>starteam://31cf2284-f114-4cf5-ad13-a6262b9B4757;id=guid/11;ns=Project;scheme=id/294;ns=View;scheme=id/716590;ns=Folder;scheme=id;scope=full/</linkUri>
        </externalLink>
... the Topic Previewer window of the Visual Studio 2010 extension of Sandcastle Help File Builder v1.9.7.0 cannot display the topic file. It truncates the topic and displays an error message:

Unable to convert topic file. Reason(s):
Invalid URI: The hostname could not be parsed.
Parsed content up to the point of failure follows.

I think this happens because the SandcastleBuilder.WPF.Maml.MamlToFlowDocumentConverter.ExternalLinkElement method tries to convert the string to a System.Uri object:
        Hyperlink l = new Hyperlink { NavigateUri = new Uri(linkUri, UriKind.RelativeOrAbsolute) };
and the System.Uri constructor does not allow a registry-based authority (RFC 2396 section 3.2.1) if the URI scheme has not been explicitly registered (with UriParser.Register) as supporting those.

I thought I could perhaps do this registration in the <system.uri> section of the machine.config file. Alas, it didn't work; the documentation says only the "http" and "https" schemes can be configured that way, and only for genericUriParserOptions="DontUnescapePathDotsAndSlashes", not "GenericAuthority".

Another alternative might be to declare the URI scheme in the .shfbproj file and change the extension to read the scheme settings from there and register them. However, the registration made for one project would then also affect all other projects opened with that Visual Studio process, and I don't think that would be right.

Instead, could MamlToFlowDocumentConverter be changed so it just generates a non-working hyperlink in this situation, and does not abort the conversion entirely? Perhaps it could then also add a warning at the top.
Coordinator
Apr 15, 2013 at 8:16 PM
I'll modify it so that invalid link URL values don't abort processing of the topic. It can insert an invalid link placeholder perhaps with a tooltip that indicates why it failed to parse in the previewer.

Eric