ASP.NET on Mono with Postgresql

Until bug 81490 was closed, Mono wasn’t capable of the ever popular “YOU DID IT WITHOUT ANY CODE” demo using Postgresql. For the unfamiliar, this is when someone demos Visual Studio’s ASP.NET designer and drags a table from the expanded database connection and drops it to the ASP.NET designer. The tool creates a connection string in the application configuration file, an SqlDataSource which uses the connection and a GridView which uses the SqlDataSource.

This code worked with Mono only if you were using SqlClient data provider. This means you were talking to Microsoft SQL Server. Most Mono users are on Linux. They want to talk to Postgresql or MySQL. Npgsql has an ADO.NET 2.0 provider model compatible library unreleased in source repository.

I’m of the opinion that declarative code such as ASP.NET or XAML or even HTML is still code. Lines of code is even moer useless a measurement here as it is in C, C++ or C#. Number of XML Nodes or number of XML Elements may be better counts of complexity in these declarative languages.

What I wanted to point out, is that it is now possible to use GridView talking to Postgresql with Mono without any code behind in C# or VB.NET.


<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>

<html xmlns=”” >
<head runat=”server”>
<title>Npgsql with SqlDataSource Example Page</title>
<form id=”form1″ runat=”server”>

<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server” ConnectionString=”<%$ ConnectionStrings:NpgsqlConnectionString %>” ProviderName=”<%$ ConnectionStrings:NpgsqlConnectionString.ProviderName %>”
SelectCommand=’select firstname,lastname,age from people’></asp:SqlDataSource>

<asp:GridView ID=”GridView1″ runat=”server” DataSourceID=”SqlDataSource1″Â >



<?xml version=”1.0″?>
<add name=”NpgsqlConnectionString” connectionString=”server=localhost;user id=test;password=test;database=test” providerName=”Npgsql” />
<add name=”Npgsql Data Provider” invariant=”Npgsql” support=”FF” description=”.Net Framework Data Provider for Postgresql Server” type=”Npgsql.NpgsqlFactory, Npgsql, Version=, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7″ />

Of course this assumes you have a Postgresql database named test with a table named people with columns firstname, lastname, age.

Bugzilla sucks less, Mono still rocks

A couple of years ago I filed a Mono bug and it was fixed the next day.

I had the same experience a last week.

I filed the bug on April 29th at 23:18 and by April 30th at 7:07 am the bug was fixed in SVN and the case closed! I even filed the bug under the wrong topic and didn’t have very good helpful information in my bug report.

The patch solved the problem and now you can use SqlDataProvider with something other than SqlClient data source. Tests with Npgsql work great. My bugzilla experience this time around was smoother than I remember from two years ago.

Thanks mono team. 8hr turn around time is AMAZING!

ALT.NET: It is not us vs. them…

It is not us vs. them.

One of the reasons I stopped doing any promoting, evangelizing(MS’s term for promoting), or really even any discussing about Linux was because I was sick and tired of the us vs. them attitude of so many.

Ayende is right and I’m sorry if I made it sound like an us vs. them. The point I was trying to make when I said “using Castle Windsor before Enterprise Library’s ObjectBuilder” is that we don’t have to wait for Microsoft’s version of something to mature before we find a good solution to a problem we are having. I’m guessing this is the same thing that Kar was saying when he wrote “NHibernate before the Entity Framework”.

If you are using Enterprise Library’s Object Builder today and it is working for you, I did not mean to suggest that you are not “with us” and that you are “against us”. If you are somehow using Entity Framework in production and it is working for you, again, I think that is great. The point I heard from Kar and what I was trying to expand on is that there is more to the .NET development experience than Visual Studio with no plugins and only the Base Class Library.

I’m of the opinion that if you are using any IoC container that you are probably already what I would consider ALT.NET. It doesn’t matter if you use Windsor, Structure Map or Enterprise Library offerings. You are out there doing something that MS really didn’t provide you tools to do easily in the BCL. I doesn’t matter if it is IoC or MVC in your WebForms or WinForms applications or any other thing that is a well known “better practice”. I view ALT.NET as not letting what is available from MS today or what is coming tomorrow stop you from doing the right thing today.

.NET is MS’s baby in the development world. Anything outside of what MS provides is what I would consider ALT.NET and even some of the things that MS does provide I would consider ALT.NET. F#, IronPython, CardSpace even are MS techologies, but they aren’t very widely used. If you are using them, I’d consider you ALT.NET.

I agree with Ayende when he says:

We as an industry has enough problems with the “We Are A Microsoft Shop, Do Not Write Non Microsoft Certified Code!” apprach, we don’t need it in the other direction.

I view ALT.NET as a label for those who aren’t afraid to use a technology outside of what is provided and supported by Microsoft. It is an attitude I would think many developers would have. Can you imagine getting all of your Java support and code from only Sun? I cannot. Why are so many .NET shops MS only in their attitudes?

Honestly, I don’t think it is a problem entirely with “we are MS only” as much as it is an awareness problem. I think many development organizations simply don’t know about many of the alternatives that are out there. It is interesting because most know that they can go buy a tools suite from Telerik or DeveloperExpress or Data Dynamics and they are told that these will help the quality and power of their product. Awareness here is raised by advertising. But how many development organizations know that using an additional framework like Castle or Spring.NET or even Enterprise Library can help with the underlying design and architecture of the software system which they develop? If I had to venture a guess, I would guess MUCH LESS. Enterprise Library may be an exception there because it does get talked about and promoted by MS.

Am I complaining? I guess only a little. I feel NHibernate was in a similar unknown state just a few months ago. After some articles and much talk on DotNetRocks and seeing it presented at conferences and code camps, now you can’t turn your head in a Starbucks without hearing a developer talking about NHibernate or some other ORM. My current complaint is that some of these other frameworks need the same treatment. Of course I shouldn’t complain. I should do something about it.