Wednesday, September 26, 2007

C#: NULL key in Dictionary<>

Few days ago I got an exception while enumerating a Dictionary<>. It was a null pointer exception for a key object. Since the keys in a dictionary may not be null I've started to dig and found the reason - multi threading writers to a dictionary without locks can cause null key (even if the writing was before the enumeration).

Solution: locks.

Friday, September 21, 2007

Access MDB on windows 64 bit using C#

Few days ago I had to install software I wrote in C# which uses Access MDB files on a Windows 2003 x64. After installing the software (compiled for 32bit) I got an error saying the Microsoft.Jet.OLEDB.4.0 provider is not installed.

After a short search I found out there isn't JET provider for x64 systems, however, Windows 2003 comes with 2 sets of ODBC providers: 64bit and 32bit, which can be accessed with 2 separate programs:
c:\windows\SysWOW64\odbcad.exe - 32bit providers
c:\windows\system\odbcad.exe - 64bit providers

When checking the list of x32 providers I found Access MDB provider! So at this point I started to check how to force .NET applications to run in x32 mode. 5 minutes later I had the solution - the .NET SDK utility CorFlags.exe:

CorFlags /32bit+ MyProgram.exe

Works like a charm. Now my program runs as before with Access MDB on Windows 2003 x64.

UPDATE: Better solution with the same results -
Project -> Properties -> Build
Set "Platform Target" to x86

Monday, September 3, 2007

SQLServer database grows big

I was looking around for a tool that will tell me how much space each table in my SQLServer database. After little search I found this sql script, which really helped me finding which table eat away all the space in the database.

btw - sometimes people forget that if you don't define your backup mode to "Simple" the transaction log will grow unless you backup the database.