[Mono-list] Assembly.CodeBase

Jonathan Pryor jonpryor@vt.edu
Mon, 07 Jun 2004 06:36:58 -0400


On Sun, 2004-06-06 at 03:24, Pedro Santos wrote:
> Hello. If I call CodeBase in Mono/Linux, I get:
> file:///path/to/assembly/assemly.dll
> 
> In Microsoft .NET/Windows I get:
> file:///c:/path/to/assembly/assembly.dll
> 
> Doens't MS.NET code have an extra '/' afer 'file:' ? 

No.  See RFC 2396: http://www.ietf.org/rfc/rfc2396.txt

A hierarchical URI is (Section 3): <scheme>://<authority><path>?<query>

As for Authority (Section 3.2): 

   The authority component is preceded by a double slash "//" and is
   terminated by the next slash "/", question-mark "?", or by the end of
   the URI.

Basically, that "extra" slash is needed to terminate the "authority"
section of the URI.  The "c:/..." isn't the authority (host), it's the
path.

> I need to isolate
> the URL from the CodeBase, and this way I can't have a way that works
> everywhere. Because Linux I have to remove `file://`, and in win
> `file:///`.

Have you considered just skipping the whole issue and using
Assembly.Location, which is just the local path?  That way, you don't
have to worry about URIs for local paths, un-escaping escaped (hex)
characters, and other issues.

 - Jon