May 2009 - Posts

June's Toolbox Column Now Online
28 May 09 02:20 PM | Scott Mitchell

My Toolbox column in the June 2009 issue of MSDN Magazine is available online and includes the following reviews:

  • ProjectLocker - ProjectLocker lets you outsource source control, defect tracking, and other common project management tasks to the cloud. Unlike open source hosting sites like CodePlex and Google Code, ProjectLocker is designed for closed source applications. Create a project, define which users have access, and, voila, you have a collaborative, online source control repository and defect tracking system. Monly prices range from free to hundreds of dollars per month, depending on the needed disk space, number of users, and installed features.
  • Blogs of Note: The Morning Brew and Morning Dew - it's amazing how much technical content is available online, from blogs to community sites to newsgroups, we are swimming in a wealth of information. Finding the most interesting content can be a time consuming task. Fortunately, there are a number of blogs available whose sole purpose is to find and share the best technical content online. Two such blogs are The Morning Brew and Morning Dew, which are maintained by Chris Alcock and Alvin Ashcraft, respectively. Subscribe to these two blogs to find new blogs or just to get a taste of the latest technical content each day.
  • Quince - Quince is a User Experience pattern browser, created by the folks at Infragistics. Each pattern includes a description of the problem being solved, provides a solution, the context of the problem, the rationale behind the solution, and steps for implementing the pattern. There are also several examples from real computer applications and websites. Next time you're working on designing the user experience, head over to Quince for guidance and advice.

This issue reviewed The C# Programming Language, by Anders Hejlsberg et al. An exerpt from my review follows:

At 754 pages, The C# Programming Language is a dense, technical, and very thorough examination of C# 3.0's syntax and semantics. The first three chapters provide an overview of the language's key features, including types and variables, classes and objects, arrays, interfaces, and events. There's also an overview of C# grammar. ... The writing style in The C# Programming Language is formal and dry. There are no figures or screen shots; the code samples given are terse. The book reads like a technical specification. However, there are several annotations throughout the book from the authors and other prominent C# software engineers both from within Microsoft and from the wider developer community. Some annotations offer a real-world example to complement the material discussed. Others include pearls of wisdom or point out common pitfalls that may surface when working with a particular feature. These annotations are written in a more conversational voice and help add context to the material. ... This book is best suited for intermediate to advanced developers who want to explore the nitty-gritty details of C# and gain a deeper understanding of the language's syntax and semantics.

Enjoy! - http://msdn.microsoft.com/en-us/magazine/dd882511.aspx

As always, if you have any suggestions for products, blogs, or books to review for the Toolbox column, please send them to toolsmm@microsoft.com.

Filed under:
Sending ELMAH Errors Via GMail
21 May 09 12:34 PM | Scott Mitchell | 1 comment(s)

ELMAH is a free, open source error logging system for ASP.NET created by Atif Aziz. This blog post assumes the reader is already familiar with using and configuring ELMAH. If this is not the case, refer to Simone Busoli's article, ELMAH - Error Logging Modules and Handlers for more information.

One of ELMAH's most useful features is that it can automatically e-mail the details of a runtime error to a specified set of recipients. This feature allows developers to be notified immediately once a runtime error occurs. (ELMAH can also syndicate recent errors as an RSS feed and, with the release of ELMAH version 1.0, ELMAH can even tweet error details.) While I've used this feature many times in the past, I ran into some difficulties setting it up to send the error e-mails through GMail's SMTP servers. You can specify the SMTP settings directly in ELMAH's <errorMail> setting or you can define it in the <system.net> section, as described in Sending Email in ASP.NET. I typically use the <system.net> setting because I also use this information in my website and don't want to repeat it twice in Web.config. Consequently, my Web.config file looks similar to the following:

<elmah>
<errorMail
from="..."
to="..."
subject="..."
async="true"
/>
</elmah>

<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network host="..." port="..." userName="..." password="..." />
</stmp>
</mailSettings>
</system.net>

The first challenge is that GMail's SMTP servers require SSL. However, you cannot specify SSL behavior through the <system.net> settings; rather, you have to do it when you instantiate the SmtpClient object, via its EnableSsl property. To instruct ELMAH to send e-mail via SSL you need to set the <errorMail> section's useSsl attribute to true, like so:

<errorMail
...
useSsl="true" />

As of the time I am writing this blog post, this attribute is not shown in the sample Web.config file, so you wouldn't know it exists unless you examined ELMAH's source code.

The second issue is that GMail's SMTP server uses port 587 instead of the standard port 25. I had correctly set the port number in the <system.net> section and believed I could then omit it from the <errorMail> section. However, I was wrong. If you omit the port from <errorMail> then ELMAH uses port 25. It does not turn to the <system.net> section and use the port number specified there.

To remedy this you can do one of two things:

  • In <errorMail>, set the smtpPort attribute to the port you want to use.
  • In <errorMail>, set the smtpPort attribute to "0". Doing so will cause ELMAH to use the port defined per the <system.net> settings.

With these changes my Web.config ends up looking like the following:

<elmah>
<errorMail
from="..."
to="..."
subject="..."
async="true"
smtpPort="0"
useSsl="true"

/>
</elmah>

<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network host="smtp.gmail.com"
port="587"
userName="..."
password="..." />
</stmp>
</mailSettings>
</system.net>

Filed under:
More Posts

Archives

My Books

  • Teach Yourself ASP.NET 4 in 24 Hours
  • Teach Yourself ASP.NET 3.5 in 24 Hours
  • Teach Yourself ASP.NET 2.0 in 24 Hours
  • ASP.NET Data Web Controls Kick Start
  • ASP.NET: Tips, Tutorials, and Code
  • Designing Active Server Pages
  • Teach Yourself Active Server Pages 3.0 in 21 Days

I am a Microsoft MVP for ASP.NET.

I am an ASPInsider.