The .NET Party Jukebox!

An entry about fun Publication date 8. June 2007 17:29

In between enjoying the gorgeous weather we have here these days (29 degrees outside today!), I've been working on a fun little project - a .NET party jukebox! Still an early beta (I've yet to design some gorgeous looking graphics for it, for instance), its now up and running on my 40" LCD-TV. It allows your guests to vote for songs, and it will then update the tracklist so that the most requested tracks get played next. Here are a few pics:

The main screen 

The voting screen

Look out for a post with more details plus the source code, as soon as I get it finished :)

Be the first to rate this post

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Instantiating an Interface?

An entry about c# 3.0 | fun Publication date 18. April 2007 22:10

Eric Lippert, author of the excellent blog Fabulous Adventures In Coding, has written two post discussing chained user-defined explicit conversions and some interresting details on how the compiler deals with them. Definitively worth reading - but what inspired this post was something that Jeroen Frijters wrote in his comment on the post:

"If an interface has System.Runtime.InteropServices.CoClassAttribute, the compiler will allow you to instantiate it..."

Now, I'm a straight up managed code guy and haven't got a lot of experience working with COM interop besides the odd DllImport - but this just sounded too interresting to pass up on investigating a bit closer...

Consider the following code:

class Program
{
static void Main(string[] args)
{
ITest wtf = new ITest();    // yep, that's an interface we're new'ing...
        wtf.DoStuff();
Console.ReadLine();
}
}

Surely, that won't compile? Yes it will, and it will run fine too - if we declare ITest as follows:

[CoClass(typeof(Test)), ComImport, Guid("C2871EB5-CDE1-4d57-BDE0-505CAA30A4A5")]
public interface ITest
{
void DoStuff();
}
public class Test : ITest
{
    #region ITest Members
public void  DoStuff()
{
Console.WriteLine("WTF!");
}
    #endregion
}

Go on, try it out... Probably not exactly what the CoClass attribute was meant to be used for, and you probably shouldn't either - but it sure is cool, and will definitively throw your co-workers off ;)

Be the first to rate this post

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Powered by BlogEngine.NET 1.4.5.0

Welcome!

My name is Fredrik Kalseth, and this is my blog - thanks for visiting! I am fortunate enough to work with what I love for a living, and this blog is essentially the biproduct of that.

I work as a senior consultant for Capgemini, and am also an active participant in the Norwegian .NET community, as an avid attendee but also as a speaker (most recently at NNUG and MSDN Live).

As a developer, I have a wide circle of interest. My primary passion is for agile, test-driven development, with focus on best practices and clean code. That said, I also love to work on the frontend, especially with web development.

On Twitter? My handle is fkalseth. On LinkedIn? I`m there too.

NDC 2010

The conference to attend this summer happens June 16th-18th in Oslo, Norway. Are you going? Be sure to catch my talk on AOP while you're there!

 

Disclaimer

This is a personal blog; any opinions expressed here are my own and do not necessarily reflect those of my employer. All content herein is my own original creation, and as such is protected by copyright law. Unless otherwise stated, all source code posted on this blog is freely usable under the Microsoft Permissive License.

What Readers Talk About

Comment RSS