Christoph Herold

Coeamyd's

...It ain't easy being green

550 Die verwendete Absenderadresse gehoert nicht zu Ihrem authentifizierten STRATO Paket.

Today, one of my customers noticed, that the contact form on his site was not working anymore. Since nothing had changed for quite a while, I went to look, and it was actually so. A short check with the error returned from the SMTP mail library (PEAR_Mail) told me, the error was

550 Die verwendete Absenderadresse gehoert nicht zu Ihrem authentifizierten STRATO Paket.

For those of you who don't understand german, it translates roughly to "The used sender's address does not belong to your authenticated STRATO account." So I thought, no shit, it never has been, because I send the mails using the email address the user enters, so my customer can simply click "reply" in his mail program. This had never been a problem before, so why was it now. What complicated the matter even more, was that there is another form on the page, that also uses data entered by the user as the sender's address, and it worked perfectly well.

To keep things short: After tracing the tcp communication, I could not find any relevant difference. So, I tested sending a mail with a simple "This is a test" message. What can I say: It worked! Björn's an my guess is, that the STRATO mail server uses a spam filter and did not accept my mail due to its content. I removed some superfluous server data always submitted when sending a contact mail, and now things are working again. That error message, though, is really misleading, and I hope they change it to something more meaningful.

So, if anyone else has this problem, try checking your mails content. It might be "spammy" :-)

Date: 16 Nov 2009 16:08

OrderBy, Distinct, and LINQ's optimization skills

Today, I was dumbfounded by LINQ's optimization skills. I built a query over a list of items, which have an assigned category and a display order. I wanted to fetch a list of the distinct categories, to display them as an overview, and have them sorted according to the order of the entries themselves. My LINQ query looked something like this:

var categories = context.Entries.OrderBy(e => e.DisplayOrder).Select(e => e.Category).Distinct();

Everything seemed to work, but when I started ordering things around, the categories would remain as they were. What I also noticed, was that they were ordered alphabetically, which perplexed me. I decided to look at the generated query, and lo and behold, there was not a single ORDER BY clause in it. I took the generated query, added my own order by clause to it, and got an error:

ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

Of course: Distinct probably just sorts the values to make filtering out duplicates easier. I left out the Distinct() method, and my ordering was the way I wanted to have it.

I have not yet worked on a sql-based solution for this, since my structure holding the categories handled duplicate filtering by itself. And my data barely has any duplicates in it anyways, so I left it at that.

But what amazed me, was that LINQ actually left out the order by on its own accord, since it would have caused an error. The LINQ to SQL parser really knows, what it's doing, although in my case, I would have liked to get some sort of warning, that the query will not behave as expected. Nonetheless, I love LINQ :-)

Date: 16 Jul 2009 11:04

jQuery UI DotNetNuke integration

I just launched a new project at codeplex aiming at the integration of jQuery UI in DotNetNuke: http://jquidnn.codeplex.com/. The first releases are already available in form of DNN module packages containing the core functionality, including infrastructural code to include jQuery and jQuery UI, two web controls for the Tabs and Datepicker widgets, and the smoothness theme.

Also available are module packages for three more themes: Cupertino, UI Darkness and UI Lightness. Further skins are actually quite easy to package and will follow over time, or when someone issues a request for one ;-)

So please, start grabbing the releases and giving me feedback.

Date: 03 Apr 2009 11:04

Bogus errors from ASP.NET compiler

I just wasted another hour, trying to figure out, what exactly ASP.NET was trying to tell me, when giving me an "ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl)." message on compiling my ascx file.

Ok, so I used a custom namespace, but I've done that hundreds of times, so that shouldn't be the problem. I also had a custom base class inheriting from UserControl. Also, nothing I haven't done before. So what was the issue now?!

I basically retyped everything concerning the namespace and class names in all files, but nothing helped. So I reverted to commenting out my code. This helped me find the issue: I used a

<% if (somethingOrOther) { %> Some code here <% } %>

construct in my ascx-file (Please don't start an argument on whether this is good practice or not. I know it's not the cleanest way to do things, but that is not the concern here :-) ), and actually forgot to put in the closing <% } %>. Ok, my fault, but shouldn't you get a better Compiler message than "ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl)."?!

So, if you encouter this error (and believe me, I've had it more than once due to typos), and are 100% positive you've spelled everything correctly, check for unbalanced parentheses!

Date: 18 Mar 2009 16:43

Be careful when reusing ListItems

Yesterday, I had one of those WTF moments. I had a page with a form for entering two addresses. Both had the same fields, including a RadioButtonList with identical items. Since the items are resourced, I decided to optimize the performance by reusing the ListItems like so:

ListItem[] items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation.Items.AddRange(items);
this.salutation2.Items.AddRange(items);

Simple eh. Everything seems to be ok. And was I amazed, when I tested it, and I always got the SelectedItem to be the one selected in salutation2. I double-checked every location were I was storing the values, in case I forgot to change the field name after copy/pasting. But everything was correct, as far as I could tell. I even checked the values submitted by the browser, they were also correct.

Finally, it hit me: The ListItem has a Selected property, and it is used to find the RadioButtonLists SelectedItem property. And since I reused the items, the first list parses its items on postback, sets the appropriate ListItem's Selected property to true. Same thing happens with the second RadioButtonList. And since the ListItems are used in both lists, the last one wins.

So, I changed my code to look like this:

ListItem[] items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation.Items.AddRange(items);
items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation2.Items.AddRange(items);

Now everything works as it should. So next time, be careful when reusing your ListItems!

Date: 17 Mar 2009 11:12

Monty Python's Spamalot musical

Last night, I went to visit Monty Python's Spamalot musical in Cologne. I had no idea, what to expect from it, and I was quite sceptical concerning the german translation. I was very surprised by the job, the whole team has done. It was very funny, in typical Monty Python style, many unexpected gags, and very ludicrous. I actually believe, they got some gags in german, that weren't in the english version. At least, I wouldn't know, how to translate it, to make it funny :-) I'm very interested in the english version, though. Humor is definitely best in the original language. Nonetheless, the musical is definitely worth seeing.

Date: 29 Jan 2009 12:29

Upgrade hassles with SQL Server 2008

Yesterday, I wasted a few hours trying to upgrade my SQL Server 2005 installation to 2008. Actually, upgrading is a simple process. You can simply select, which instance to upgrade, and the installer does the rest. It worked absolutely fine for my regular instance. I got some installation errors for a component, but didn't mind that at first. Everything seemed to be working.

At least I thought so, until I noticed, WHAT component got the errors. The SQL Server Management Studio was not installed. And the older 2005 version isn't able to connect to 2008. Bummer.

So I thought, let's try to reinstall it. Same error: "The error code is 2349." When you copy the details to the clipboard, you at least find the URL http://www.microsoft.com/products/ee/transform.aspx?ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=10.0.1600.22&EvtType=0xF45F6601%25401201%25401, that gives you the information, that the SQL Server Native Client is causing the trouble.

So I tried upgrading my SQL Server Express instance, but that was also dismissed with an error. Next, I uninstalled my SQL Server 2005 express instance, uninstalled the native client, and now added the Management Studio feature to my SQL Server 2008 instance. Same error, this is really getting frustrating.

So now, my last resort is to uninstall the whole d*rn thing and try to reinstall it. At least the installation only takes about 2 hours *cough*.

UPDATE: Even the complete uninstall did not help. As the error message states, the Native Client is supposedly not installed from the sqlncli.msi package. Well, I even uninstalled and reinstalled ONLY THAT package, to no avail. I'm still getting the same bogus error, when I try to install SSMS. Any help is welcome! I'm out of ideas.

But at least I'm not all alone with my ss2008 install problems. A friend of mine had other issues, but at least he was able to resolve them: http://www.entwicklungsgedanken.de/2009/01/28/installation-problems-with-sql-server-2008/comment-page-1/#comment-252.

UPDATE 2: I have found out, that it's the Visual Studio Tools for Applications 2.0 installer, that is causing the problems. But I still have no idea why.

UPDATE 3: Rollback all rants :-) I found the issue. A file could not be replaced/updated by the installer. This was due to the fact, that my hard disk seems to be defective. The file could not be read, even less replaced. After renaming it, the installation went fine. So now, I have performed a scandisk, the errors have been cleared, and everything is in order. Guess I'll be backing up more often now, though.

Date: 28 Jan 2009 09:36

Developing WCF with HTTPS

I just ran across a really nice article describing how to create a self hosted WCF service using HTTPS bindings. It's a nice step-by-step instruction on how to create your own certificates, adding them to your store, configuring the Windows HTTP runtime, and configuring your WCF service. You can find the article on CodeProject at this url: http://www.codeproject.com/KB/WCF/WCFSSL.aspx. Really nice article, helped me a lot. Kudos to Chris.

Also, Steve Johnson created a nice little GUI for the httpcfg command line tool, which you can find here: http://www.stevestechspot.com/ABetterHttpcfg.aspx. It's a nice addition to the article, so you are not completely bound to the console :-)

Date: 13 Jan 2009 20:22

DotNetNuke now with jQuery

I have been using jQuery with DotNetNuke for a while now, and was very happy to finally see it integrated into DotNetNuke. What makes me wonder, is that there is no central method for including it in DNN 4.9.1. The library has been placed into the folder ~/Resources/Shared/scripts/jquery, but the one usage I could find does not use the ClientScriptManager to include the script. Instead, it manually creates a Literal script control. This will cause the script to be included multiple times, if different controls use it simultaneously. Perhaps this will be "fixed" in a future release. Perhaps adding a method to the ClientAPI for including it would be a good solution for a global include mechanism.

Date: 07 Jan 2009 10:06

Outlook 2007 stationeries and image spacing

Today, I had to make a template for a mailing. I decided to create it as a stationery for Outlook, since this was the desired way of sending the mails. Not much to it, one might think. I created the HTML for the template (of course using the dreaded layout tables, since OL2007 went back to the stone age with its rendering engine), and copied it and the required images to the stationery folder. Having done that, the stationery showed in my list and I was able to create a mail using the template.

But what's this?! Were do the gaps in between the images come from?! And why are my shadows not aligned anymore?! Outlook simply went on and pratically destroyed my layout. I basically tried everything that came to my mind, trying to fix the gaps: modified paddings and margins using css, html attributes, added fixed widths and heights, nothing seemed to work. I even removed all the tables and simply placed two images after one another, no white space in between. Still, I got my gaps.

When everything seemed hopeless, I decided to simply send the mail the way it was. Guess what: everything is in perfect shape, when the mail arrives. No gaps, everything is aligned perfectly. I can even simply forward this mail, and it looks great in the editor. So the gaps only show, when you first create the mail using the stationery. Afterwards, everything is as it should be.

<rant>Now that's what I call a consistent user experience! Great job from the folks at Microsoft. I wasted a whole day trying to work around this bug.</rant>

And by the way, using stationery is probably not the best solution, since Outlook completely reformats your code and places all those unneccessary MSO* css styles in your mail's code. So if something goes wrong with your mail, you might consider NOT using Outlook to send it in the first place.

Date: 14 Dec 2008 22:50