Friday, 26 August 2011

SQL Agent Immediately Stops

We just run into an interesting problem where starting the SQL Server Agent would start and then immediately stop. No errors were reported in the event log, but running the following via the command line returned "StartServiceCtrlDispatcher failed (error 6)"

"[[your SQL Path]]\Binn\SQLAGENT.EXE" -i [[sql Instance]]

Googling the error in question returned this forum post which contained the solution. We had reinstalled the service and the account that we were running under did not have the permissions to update / overwrite something (it wasn't the error file in question). Running the agent under a different account solved the issue; would be good to look into what the exact problem we are encountering is, but it's enough that it's running for us right now.

Tuesday, 23 August 2011

Exceptions inside IComparer.Compare(x, y)

When writing or using an implementation of IComparer.Compare(x,y) you encounter the following error message:

Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results

It is highly likely that the code within the "Compare" statement is throwing an exception. We encountered this problem when trying to access an array out of bounds in a particular scenario. Updating our tests and our code to return a correct result in this scenario fixed the issue for us.