If the path contains a hash ("#"), this property returns an invalid URI.
e.g. an assembly in c:\dir\#dir will return "file:///c:/dir/#dir", which has the following components:
schema name = "file"
hierarchical part = "///c:/dir/
fragment = "dir"
In this case, the example in the contribution above (using System.Uri) would NOT work.
Consider using Assembly.EscapedCodeBase instead, which works just fine with System.Uri. (System.Uri will unescape all other escaped characters.)
Update: MS considers this "by design", since some Apps seem to handle these invalid URLs correctly (read: it works, even if the URL is not correct). http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=333763
I believe the only way to handle those unescaped URIs correctly is to remove the "file://" prefix and leave the rest untouched. Stay away from any standard conforming URL parsers with this CodeBase, they will break in the rare scenario of paths that include hashes.