Steven Kuhn

Web developer. Avid gamer. Tech geek.

How to Build Your Own Home Phone Server

Using Asterisk in conjunction with Google Voice will help you dramatically reduce your landline phone bill

Google Voice. Skype. VoIP-to-PSTN providers. SIP-to-SIP calls. All of these technologies and products allow you to make calls that are either free or much cheaper than on your landline. Wouldn’t it be great if you could escape the clutches of your Telco and connect your home phone to these services? A phone server like Asterisk can help you realize this dream.

Short for Private Branch Exchange, PBX is a telephone exchange that is often used by businesses or offices. If you work a 9-to-5, chances are that your phone system is PBX-based. The short definition is that it’s essentially a network of phones connected to a main public switched telephone network (PSTN) that functions in a similar manner to a data network. In fact, in many instances today, the voice network is actually a VoIP-based network operating over data lines.

There’s a cheap and fairly simple way that you can ditch Ma or Pa Bell. The trick entails using an old PC to set up your own PBX in your home, and then connecting this PBX to Google Voice.

This article has really sparked my interest in using Asterisk with Google Voice. I have a Nexus One phone that integrates fantastically with it, although reception is questionable at times inside my apartment. This certainly could be the solution I need for a quality landline in my apartment without requiring a separate provider/phone number.

ASP.NET Deployment Needs to Be Fixed

I deploy Tekpub, on average, 3-5 times a week. This used to scare me every single time I did it - for various reasons: no rollbacks, I’d overwrite some of Avery’s changes, I’d forget something. Imma go ahead and say it: ASP.NET Deployment is a joke.

I agree with Rob that the state of deployment for ASP.NET applications is lacking. Issues arising from deployment is something that the team I work with continually have to deal with. It seems that the build and deployment tools that Microsoft provides are so complex that it requires a dedicated person solely responsible for managing them. When we moved to Team Foundation Server 2010 we wanted to incorporate deployment as part of the build process. However, trying to adapt Windows Workflow to a custom build process is an absolute nightmare. I’m not saying having an automated build and deployment process is trivial, but it doesn’t need to be that complex.

Disposing a WCF Proxy Using an Extension Method

A while back I read a blog post by Dan Rigsby about why you should not use C# using statements on a WCF service proxy class even though it implements IDisposable. Basically it comes down to the Dispose() method calls Close() which can throw an exception preventing the service proxy from being disposed properly. The solution by Dan Rigsby involving a wrapper class and another solution by Erwyn van der Meer (which provides a helper class that you can derive from) both allow you to use the using statement and still properly dispose of the proxy.

I wrote an extension method below will dispose a service proxy properly, but it doesn’t require you to change that proxy in any way. By providing an extension method around ICommunicationObject, any WCF class that dervives from it (ClientBase, ServiceHostBase, etc.) will have this method available as well.

With that method in place, all you you have to do is call TryCloseOrAbort() in a try-finally block to make sure it is called even if an exception is thrown.

Extension Method to Sort ListItems in a ListControl in ASP.NET

Yesterday I needed a way to sort the items in a ListControl (in this case, a DropDownList) after the list had been populated. The reason for that is after I databound my DropDownList from a collection of items, I inserted a few more ListItems depending on certain circumstances. Instead of trying to hack some method of inserting those items in my original collection, I wanted a more elegant solution. After I came across a post on Google I came up with a solution using an extension method and LINQ:

I wanted a simple solution so I didn’t do any performance metrics on it. Things I might change is add ability to sort by ListItem.Value, add the ability to change the sort direction, or perhaps sort by a custom comparer. So if you want a way to sort a ListItemCollection, give this a try and let me know what you think! :)

Update (July 16, 2009) The post that I found http://coercedcode.blogspot.com/2007/08/sorting-listitem-collections-in-aspnet.html no longer works. If I find it, I’ll update this post.

An Error Was Discovered Processing the <Security> Header

A coworker and I were troubleshooting an issue we were having concerning a .NET call to a webservice that used WSE Security. Our client derived from Microsoft.Web.Services2.WebServicesClientProtocol and every time we tried to call the webservice this error would appear:

An error was discovered processing the <Security> header

A quick search on Google returned a quick, easy solution: verify that client and server have their system time in synch (a 5 minute window is allowed). Once the server time (about 6 minutes apart) was fixed the issue immediately disappeared.