This project is read-only.


Invalid relative baseUri parameter used for XmlReader


There are three spots in the code base where XmlReader.Create() is called with a baseUri as the last parameter:
The problem is that this baseUri is a string like "System.Data.Resources.SqlClient.SqlProviderServices.ProviderManifest.xml", which is a relative Uri instead of an absolute Uri. Accoring to RFC 3989, only absolute Uris are allowed as base Uris.

The .NET framework doesn't seem to validate whether the base Uri is absolute, so it works there, but it throws an exception under Mono, which apparently validates it.

I'd suggest prefixing the parameter with "file:///" or removing it (not sure what it is used for, a quick test showed no difference when removed).
Closed Jan 23, 2014 at 8:49 PM by mgirgin


moozzyk wrote Sep 6, 2013 at 8:10 PM

The baseUri is being used when loading artifacts to be able to report errors (i.e. after obtaining the reader from the GetXmlResource we pass it to the StoreItemCollection/EdmItemCollection/StorageMappingItemCollection ctor and if the validation fail we use the BaseUri to be display details about the error).

Prefixing the resource name with "file:///" is not semantically correct - since we are talking about resources which should be resolved with respect to the assembly they were embedded - but might be an option if we can't find a better way of fixing this.

akoeplinger wrote Sep 6, 2013 at 9:08 PM

Thanks for taking a look!
I think it doesn't really matter which URI scheme you choose, could also be resource:// or something similar.

moozzyk wrote Sep 6, 2013 at 10:04 PM

Yes, I thought about res:// but was not sure if it was going to work. On the other hand this is not for some random files living in the wild but for the files that we ship as part of EF or shipped by providers. This means that as a user even if you get an exception (which should never happen) you are not able to do a lot about it so maybe passing null is OK here.

empann wrote Oct 27, 2013 at 1:47 AM

I'm trying to use Entity Framework 6 under mono and I'm also getting this error. The impact is low under .NET framework but very high under mono.

akoeplinger wrote Oct 27, 2013 at 6:10 PM

empann: I've provided a pull request to Mono that takes care of the exception:
If you use the latest Mono from master branch, it'll just work.

However, the issue in EF should be fixed nonetheless, as it's just wrong to pass a relative baseUri.

RoMiller wrote Dec 12, 2013 at 9:34 PM

EF Team Triage: Moving issues with Impact set to Low out of the 6.1.0 release as we only have time to address High and Medium issues in this release. We will re-triage these issues for future releases.

This does not exclude someone outside of the Microsoft EF team from contributing the change/fix in 6.1.0.

ajcvickers wrote Jan 14, 2014 at 10:56 PM

Fixed in fe6936ea4a83 by ErikEJ

Fix for issue