Archive for May 2009

Columbus iPhone Developers User Group (CIDUG) meeting

The May CIDUG meeting was last night at the OCLC campus, and Marc Peabody of EdgeCase did a nice job showing some of the intricacies of Objective-C. Overall, I liked his presentation and humor, but I did find one egregious error in his slides:  guitars are way, way cooler than Miles Davis.

Anyone in the central Ohio area who is interested in development for the iPhone should plan to attend the CIDUG meetings.  Here is the Google Groups link for CIDUG:

Columbus iPhone Developers User Group (CIDUG)

Terminator Salvation movie night

We went out after work today to take in the newest installment of the Terminator saga, Terminator Salvation. The movie itself was somewhat disappointing, but as a team building exercise, the camaraderie was worth the effort.

I have a theory about movies. The ability for a movie to interest viewers with plot and conflict is inversely proportional to the amount of special effects. Terminator Salvation does nothing to refute my postulate.

If at first you don’t succeed, try try (catch catch) again

So I am cruising through the ASP.NET C# MVP web project we are working on, and happened upon this method (again, the names were changed to protect the not so innocent):

private void mView_LoadObjects(object sender, EventArgs e)
{
    try
    {
        try
        {
            BusinessLayer.Class1 bizClass = new BusinessLayer.Class1();
            mView.objects = bizClass.GetObjects(mView.ID1, mView.ID2);
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message);
            throw;
        }
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
        throw;
    }
}

However, the fun didn’t stop there.  A little further down the class, I found this:

private void mView_LoadOtherObjects(object sender, EventArgs e)
{
    try
    {
 
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
        throw;
    }
}

I am thinking that the catch block on this second example was not hit very often.

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.