Friday, July 9, 2010

Generics, Performance of collections

It's not uncommon for developers to make assumptions regarding the performance of an application.  Frequently this is caused by not being given a performance target for operations based on real world load, during the design process.  Therefore, we don't always develop tests to validate a design, proving that one design over another is better.

In a recent article from Bill Wagner, he provides a very good overview of the reasons that some collections are better than others, depending on what they contain, and how they are used.  I strongly recommend reading that article here.

Perhaps in an upcoming post, I can outline some of basic differences between the generic collections that the .Net framework provides, including some examples of how their selection affects performance.

Thursday, June 10, 2010

Solved: CLR20r3 error when running a new service / application

I recently was tasked with creating a simple application that would send out some emails on a schedule.  There are a number of ways to accomplish this, but I choose to create a small console application to do the job.

The procedure was rather simple, the application contained a few minor settings, a database connection string and some SMTP configuration settings.  When I finished developing the application, it wasn't worth building a separate installer for  it, so I built it, copied it to the server where it would reside, a recently deployed Windows 2008 server.  I opened task scheduler, set up the schedule that I wanted, and then manually requested that it run.

What I expected was that I would find a few entries in the event log, as I had told the application to record when it started, and when it finished, and if it encountered any errors.  What I found in the event log though was an error indicating that the application was causing an error, with the Event Name: CLR20r3?
Fault bucket , type 0
Event Name: CLR20r3
Response: Not available
Cab Id: 0

Problem signature:
P1: emailnotices.exe
P2: 1.0.0.0
P3: 4c1166a8
P4: System
P5: 2.0.0.0
P6: 4a275e12
P7: 38a9
P8: 116
P9: System.Security.Security
P10:

Attached files:
So I did a little searching on the web to see if others had encountered the same error, and found some interesting articles about the code, but nothing that really applied to my situation.  I thought it was odd that the start time information was never even recorded in the event log, the application simply stops responding with the error code.  So on a hunch, I commented out all of the calls to the "EventLog.WriteEntry" method, recompiled and uploaded the executable to the server.  Ran the application, and sure enough, that resolved the problem.

So if you're encountering this error, try commenting out any calls to the event log, and see if that resolves your problem as a test.  If it does, then your probably experiencing the same security issue that I was.

By changing the security options on the scheduled task, telling the application to run with highest privileges, I was able to get things running as I intended.  Now my app runs happily, recording information to the event log as I wanted.  Hope it will save you some time.
 

~Cheers