Pernah ngalamin error kuning kayak gini waktu deploy web app di IIS 7?
“System.BadImageFormatException: Could not load file or assembly 'SharpMap' or one of its dependencies. An attempt was made to load a program with an incorrect format.”
FYI, my dev environment:
- Windows 7 Ultimate 64-bit (did I mention I do coding on MacBook Pro :P ?)
- IIS 7.0
- SQL Server Express 2008
Pada contoh error message di atas, ada masalah dengan assembly SharpMap. Langsung menyalahkan assembly SharpMap (yang sebenarnya, paket yang gw download masih hasil build dari trunk, not really final yet).
Langsung pergi ke MSDN untuk cari apa dan penyebab exception System.BadImageFormatException. Not helping much, but one thing I notice that exception should be related to platform, x86 or x64. After googling and binging, either on SharpMap portal at codeplex or anywhere, not helping much. I suspect it’s not directly related to the SharpMap assembly itself. Its should be related to configuration.
Iseng-iseng buka konfigurasi IIS 7.0. Tidak menemukan sesuatu yang terkait pada property pages untuk men-setting web app yang bersangkutan. Lalu coba masuk ke Application pool, klik kanan pada DefaultAppPool (gw pakai DefaultAppPool aja, malas bikin baru, toh app yang pakai cuman satu). Dan menemukan setting “Enable 32-Bit Applications”. Ahh…it should be it.
Then, I set “Enable 32-Bit Applications” to True. Viola…it works. So, looks like SharpMap assembly I have, it targeted to 32-bit platform.
That’s all, hope this post will help somebody out there.