[Mono-bugs] [Bug 322328] Uri: UriFormatException on linux for files with colons

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue May 20 15:46:35 EDT 2008


User ajorgensen at novell.com added comment

--- Comment #12 from Andrew Jorgensen <ajorgensen at novell.com>  2008-05-20 13:46:35 MST ---
In my case the app that was failing was NAnt.  The exception is thrown in
XmlDocument.Load(string filename).

        private XmlDocument LoadBuildFile(string uriOrFilePath) {
            string path = uriOrFilePath;

            //if the source is not a valid uri, pass it thru.
            //if the source is a file uri, pass the localpath of it thru.
            try {
                Uri testURI = new Uri(uriOrFilePath);

                if (testURI.IsFile) {
                    path = testURI.LocalPath;
            } catch (Exception ex) {
                logger.Debug("Error creating URI in project constructor. Moving
on... ", ex);
            } finally {
                if (path == null) {
                    path = uriOrFilePath;

            XmlDocument doc = new XmlDocument();

            try {
            } catch (XmlException ex) {
                Location location = new Location(path, ex.LineNumber,
                throw new BuildException("Error loading buildfile.", location,
            } catch (Exception ex) {
                Location location = new Location(path);
                throw new BuildException("Error loading buildfile.", location,
            return doc;

The exception is thrown because they are explicitly NOT passing a URI to
Load().  They strip off the file:// prefix if it's there.  Looking at the MS
docs this may actually be correct, at least in principle.  The ms docs for this
method say that filename is a URL and that that "the URL can be either a local
file or an HTTP URL (a Web address)".  Our own docs say URI rather than URL.

In practice, though, one can pass a file:// URI just the path part to the
method and the MS class libraries will do the right thing.  It looks to me like
Miguel's patch is the right way to fix this problem.

The msbuild stuff mdtool uses also exhibits the same bug, probably for similar

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list