SharpDevelop, A Getting Started Guide
SharpDevelop is truly an old friend of mine, with regard to having a constant programming companion on the MS Windows platform. Not only is it an always-free proposition, but it is vastly simpler to set up an application structure, include libraries, and become productive quickly, than an equivalent object-code program would be. Object-code compilers will always be with us, but I think at this point the numbers of .NET programmers have probably surpassed those of most other programming disciplines (and this is another advantage, because more users means more code support, better documentation, more sample code, more and better libraries). You can also program C# on other operating systems by using the Mono framework, although I personally have not tried this. To top off the list of benefits, the .NET library is almost guaranteed to be installed on any computer where I might find myself employed.
With only a few exceptions, I do almost all my own routine programming work using C#/.NET and using SharpDevelop. One drawback that I can identify at present is that SharpDevelop cannot debug 64bit code (although it can build 64bit programs which can be run from the Windows shell), but I’m sure this will change with time. Another drawback is that the XAML editor is not as easy to use as I would like, and at times it seems downright unfriendly to the idea of free-form design. After spending time with the XAML designer you can get used to its idiosyncrasies, and it turns out these are more attributable to dementia among Microsoft engineers than the SharpDevelop team.
What Is SharpDevelop?
Just to provide a little background and context, SharpDevelop is a free, open source, IDE (Integrated Development Environment), built using the .NET framework, by a small development team in Germany. SharpDevelop is designed to perform programming project management for .NET targets and to act as a front-end for several language compilers. In essence it’s a light-weight version of MS Visual Studio, and while Visual Studio costs thousands of dollars, SharpDevelop is and probably always will be free (though they might have some kind of business model in mind to generate revenue). I won’t deny that SharpDevelop has fewer features than Visual Studio, but you have to consider how much smaller their development group is than the Microsoft hoard. The plus side of that however is that SharpDevelop runs at a fraction of the RAM and CPU cycles than Visual Studio does.
The Visual Interface Designers
Version 4.4 is the current distribution for SharpDevelop, and version 5.0 is released in beta 2 as of 2/19/2014. I have used SharpDevelop since at least version 3.2 , and I have always had success with WinForms (the System.Windows.Forms namespace) for doing quick visual design of a user interface before entering code. The new visual editing system, based around XAML (eXtensible Application Markup Language), could stand some improvement in my opinion. I know the positioning and layout control could be made more intuitive, as it currently represents a throwback to a more primitive time. Sifting through the available container panels for one which could anchor child controls was like being lost in a sea of barely usable UI decisions. After finding one that met my needs (the DockPanel) it turned out that the mechanisms for positioning and anchoring child controls are about as non-obvious as it’s possible to get. Another strange and unfriendly design decision concerning XAML is that a number of primary controls (including the top-level window control) may only contain one child control.
If you’re able to accept some of the XAML detractions, the .NET library and SharpDevelop still offer ease of use and functionality superior to many other development environments. SharpDevelop is able to accomodate several languages, such as C++, C#, F#, and VB.NET, as well as tools for profiling and unit testing. It is also able to output several important build targets, such as Silverlight, ASP.NET, WIX, the standard desktop application, and something called WCF (sorry I haven’t looked too closely at this one). In addition, SharpDevelop version 4.x accomodates the languages Iron Python, Iron Ruby, and a language called Boo, although I’m not sure if these will continue being supported with version 5.x . If you’re a Microsoft junkie, or if you’re forced to work in a Microsoft Windows environment, then SharpDevelop will meet many of your needs.
SharpDevelop Installation Details
There are a great many useful and interesting applications which were built in the early days of .NET which are still floating around on coding sites , and SharpDevelop v3.2 is able to open these older project formats and convert them to the newer format. For this reason I always keep one copy of SharpDevelop v3.2 within easy reach for performing these conversions. You can download all the SharpDevelop versions here. This download page also describes related software which can be used in conjunction with SharpDevelop, such as the Windows Platform SDK and the .NET Framework, so it’s a useful resource. Of course the .NET library itself has changed significantly from its early incarnation, so getting those older applications to compile is a different issue.
I’ve found that it’s possible to have multiple versions of SharpDevelop installed, since there don’t appear to be any library dependency problems, and I just keep a shortcut to each one handy. The SharpDevelop team also developed their own .NET code disassembler called ILSpy, and if it doesn’t install with SharpDevelop, then you can always download ILSpy from here. Download the ILSpy binaries unless you’re planning on joining the development team. You can access ILSpy from within SharpDevelop by right-clicking on a .NET library element, and then selecting Open ILSpy. If it can’t find ILSpy, just provide it the full path to ILSpy.exe.
Starting a New Project
If you plan to use WinForms then open a new project as C# | Windows Applications | Windows Application. Otherwise if you wish to use XAML and the Windows Presentation Foundation, then open a new project as C# | WPF | WPF Application. The new project wizard will take care of adding necessary assembly references to support each particular build. If you’re new I would recommend playing around with WinForms for a while, since it’s more intuitively easy to use, and then later graduate to WPF. The new project wizard requires you to supply a directory where the files will be placed.
Getting Around the IDE
The project build button is in the toolbar, and running the project within the debugger is the solid green arrow right next to it.
The build output appears at the bottom of the IDE in a window titled Output.
You can add program startup code inside the MainForm constructor
Clicking the Design button at the bottom of the editor allows you to drag and drop visual elements from the tools panel onto your WinForm.
You can access properties of the visual control, and create event callback methods on them, from the properties panel.
Double-clicking directly on the visual control in most cases will create a mouse button-click event within which you may add your code.
Of course there are several dozen built-in controls to use, so the button example is just the tip of the iceberg. You can get contextual help on any C# language or .NET library element by simply placing your cursor within its text and hitting the F1 key. If this doesn’t work for some reason you may have to install the Microsoft help system manually.
Project settings are accessed by right-clicking on the project name within the project explorer panel, and selecting Properties.
Common Build Errors
When performing a build, if you get error messages concerning missing libraries, you can add these references from the project explorer panel. Simply right-click on the references project item, and select Add Reference. From the add references dialog, select the GAC tab and find the assembly you need to add (this may involve using the Microsoft Help to determine which assembly is required for a given .NET library element). Double-click the assembly you wish to add, then select Ok. After adding the assembly, then add a using statement at the top of your source file so the assembly contents can be accessed.
That’s all there is to creating a C#/.NET application using SharpDevelop. These programs are dead easy to build, which is why the world has migrated to these more advanced languages and build environments. I can tell you from experience that the C# Using feature, assembly references, and encapsulation of everything within classes make it enormously easier to work with than C++ , which includes headers and libraries from disparate sources and often results in endless lists of compile and link errors.