ELMAH for ASP.NET

My company has been doing ASP.NET development for a few years now, and we have had varying success in dealing with exceptions. In a Scott Hanselman blog post, I found out about ELMAH (Error Logging Modules and Handlers), which can assist development of ASP.NET web sites.

After some configuration issues in the Web.config file, we were able to get it working fine on my local machine. We have not tried using it in a production environment, but I would guess that it should work fine as long as we create the appropriate folder on the web server to save the XML files.

I suspect that we have only begun to scratch the surface of what is possible with ELMAH, but I would reiterate what many others have said. Anyone doing ASP.NET web development should be using ELMAH.

Here are a couple of links:

ELMAH project home (Edit: link changed)

DotNetSlackersArticle introductory article by Simone Busoli (Edit: link to the page ‘http://code.google.com/p/elmah/wiki/DotNetSlackersArticle’ now shows as dead)

AudioServicesCreateSystemSoundID error -1500

The iPhone application is going along fine, and I decided to look into adding some sound to the application. So, I found a .caf sound file on my Macintosh, brought it into the project, and then used the SoundEffect class from the Metronome sample application.

Here is the initialization code that I am using:

theSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle 
                pathForResource:@"soundfile" ofType:@"caf"]];

When running the application in the Simulator, everything worked fine and the sound played loud and clear. However, when running the application on an actual device, there was no sound to be heard. Stepping through the code, I traced the problem down to initWithContentsOfFile method of the SoundEffect class, which was returning an error -1500 on this line of code:

OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)aFileURL, &aSoundID);

After trying to solve the problem by poring over the code, I decided on a lark to try to use the same exact .caf file that the Metronome application used. Of course, this worked, which apparently means that if you get the error -1500 from the AudioServicesCreateSystemSoundID call, it is possible that you are using a sound file that is compatible with the Mac but not with the iPhone.

Brought to you by The Department Of Unnecessary Code

Another nicety that I happened upon, this time from the C# realm. The names were changed to protect the innocent.

theClass.uniqueID = (id != null) ? id : null;

Looks like someone just figured out how to use the ternary operator and was determined to use it.

Using Http library for the Palm OS

I was asked some time ago to look into the possibility of SSL communications with Palm OS phone based devices. The NetLib was already being used, but it did not have native support to communicate over SSL.

After a bit of searching, I decided to try to use the Http library that is provided on certain models of Palm OS devices (OS 5.x devices such as Centro, Treo, LifeDrive, and some Tungstens). The model was not an issue, as the customer was already using Treos, and the library seemed to have everything I needed to make a go of it.

The documentation seemed pretty thin on the Http library, about the only things I could find was some mention of the library in the PDF document Palm Developer Guide, Palm OS Platform Software and Hardware (Revision J, April 30, 2008), and an example program on using the library.

I downloaded the sample code provided by Palm, and with some small tests it seemed to work like gangbusters in both http and https mode. However, the first time I threw a real-world test at it, the code started erroring pretty quickly.

After much consternation, I finally tracked the problem down to the READ_CHUNK constant defined in the Peer.c file. By changing it to 32000 instead of 65535, it seemed to work much better.

The reason for this would appear to be that the READ_CHUNK constant is compared with and assigned to 32-bit integers, but this value is cast to a 16-bit integer when used in the NetLib calls, which was of course causing all sorts of wackiness.

Also, I quickly discovered that, since we were using a test SSL certificate, that the communications were failing early on in the initialization process. As a result, I had to set up a callback function that was used by HS_HTTPLibSetSSLServerCertConfirmProc. This callback in turn calls HS_HTTPLibServerCertConfirm and then just returns zero, which allows the invalid SSL certificate to be used.

iPhone application based on the “Utility Application” template and the “i” (info) button

So you have created an amazing iPhone application and based it on the Utility Application template in the iPhone SDK. This template gives you a main view and an alternate view that you can use for preferences or other information. This alternate view is seen by tapping on the info button (which is a round graphical “i”)  in the bottom right corner of the main view.

The development is going like gangbusters, your application is looking real good. You have been developing and testing in the simulator and all is working fine.

But your world gets rocked when you put the application on an actual device. All of a sudden, no one can tap your “i” button, or it takes several tries to finally tap it to display the alternate view.

I feel your pain, as I found myself in the same exact situation.

Well I have found a solution. Apparently the bounding rectangle for the info button in the MainView.xib is pretty small, so I inserted the following code into the viewDidLoad method of RootViewController.m:

CGRect newInfoButtonRect = CGRectMake(infoButton.frame.origin.x - 20,
                            infoButton.frame.origin.y - 20,
                            infoButton.frame.size.width + 40,
                            infoButton.frame.size.height + 40);
[infoButton setFrame:newInfoButtonRect];

Now the info button works every single time.

But I cannot take the credit, here is the link that led me to this solution:

Problem with infoButton on Utility based app (link redacted)

Yet another software development blog

One thing that the internet doesn’t really need is a zillion and one software development blogs, one zillion software development blogs is just the right number.

However, I stumbled upon this Visual Basic .NET nugget at work one day and just couldn’t resist…

Private Function getCustomers() As Array
 
    'do something here
 
End Function

This blog is in honor of my discovery. Please stay tuned for lots more nuggets o’ gold, random thoughts, and sometimes maybe even problems I have run across and how they were solved.