Managed Pointers to Managed Objects (or Aliases for Objects) in C# and Visual Basic .NET

One of the biggest advantages of managed frameworks/platforms like Microsoft’s .NET Framework (and it’s Linux-counterpart, Mono), and Java is that you, as a developer, have a choice of not mucking around with pointers. To be totally honest, with Java you’re forced not to – in C#, it’s a choice you have to make.

There’s plenty of good reasons for not using (unsafe!!) pointers, but that’s not the issue here. The question is, what if you want something to “point” to another object, and synchronize it’s value automatically, without resorting to unsafe pointers? There’s actually a quite simple answer using just a single line of C# code.

Whereas in C++ you could write something like what appears below, in C# you’d have to declare it as unsafe, then jump through a hundred hoops to get it to properly point to a managed object:

Continue reading

SharpDevelop “invalid EventMemberSpecifier” Error & Solution

The Problem

SharpDevelop, for those of you that haven’t heard of it, is a very light-weight open source alternative to Visual Studio 2005. It doesn’t have all the frills and features that Microsoft’s professional IDE does, but in exchange it gives you much less bloat, faster speeds, and quite a few nifty built-in tools like SVN integration, FxCop auto-checking, code profiling, language conversion (C# <-> VB.NET <-> Boo#), and a bit more – but it has its drawbacks, too.

SharpDevelop is intended to be a 100% open source drop-in replacement for the Visual Studio IDE on Windows (there’s MonoDevelop for Linux if you like), and for the most part, it works just fine. But once in a while, an odd quirk pops up that’s rather obvious & common… yet unsolved and makes us wonder.

Continue reading

Image Lists or Resources?

One of the nicest things about Visual Studio and the .NET language is choice. You have plenty of choices, plenty of options, and plenty of different ways to confuse and confound yourself. Take, for instance, icons/images as “labels” for buttons: what’s the best way to do that?

At face value, there are two options, either of which should theoretically work just fine, and get what you need: Image Lists and Resources (resx files). Technically, there’s even a third option: compiling local resources directly into your application. Anyway if this all sounds like Greek to you, no worries, here’s the low-down on these two (three) different ways of adding an image to your file.

Continue reading