Monthly Archives: September, 2009

AOP – Aspect-oriented programming with PostSharp

A really nice library seems to be PostSharp – its easy to install, easy to use and its still licensed under LGPL. Hope it will stay this way.
At dotnet-snippets i found another nice example (besides the ones at the authors homepage). It shows how to use PostSharp for validating parameters.


Abstract forms with designtime support

A nice article about abstract forms in Visual Studio can be found at Urban Potato. Its useful to download the example project cause the article is well explained but doesnt provide the full code to get the whole impression of the provided technique.
For me it seems a nice solution but doesnt satisfy me to the end: I want to add some controls and moreover some functionality (as protected methods to have access in derived classes) provided by these controls to the abstract base form – but as far as i see its not possible with this approach. Nevermind, read and learn.

Inglourious Basterds – September 15, 2009

No matter if you are a Quentin Tarantino fan or not – watch it! 66.604 viewers attest it (votes on IMDB at September 23, 2009) 😉

Reverse mapping of drive letter to server address

You need the pure server address of a remote directory mapped to a drive letter? Try this:

[DllImport("Mpr.dll", CharSet = CharSet.Auto)]
private static extern int WNetGetConnection(
    [MarshalAs(UnmanagedType.LPTStr)] string localName,
    [MarshalAs(UnmanagedType.LPTStr)] StringBuilder remoteName,
    ref int length);

public static String GetServerPath(char driverLetter)
        int length = 1024;
        StringBuilder result = new StringBuilder(length);
        WNetGetConnection(driverLetter + ":", result, ref length);

        return result.ToString();
    return null;

public static String GetServerPath(String filename)
    if (filename.Length > 1 && filename[1] == ':')
        String serverpath = GetServerPath(filename[0]);
        if (serverpath != null && serverpath.Trim().Length > 0)
            filename = serverpath + filename.Substring(2);
    return filename;

Hello world!

Console.WriteLine(“Hello world!”);