This Blog Has Been Moved !

This Blog Has been moved to http://aleemkhan.wordpress.com

There is a small problem with System.Drawing.dll in VS.NET 2003. Sometimes you get an Arithmetic Exception and the program is terminated. If u get this "Arithmetic Exception" in System.Drawing.dll, then there must be some spy software or some virus installed on your system which has hooked the system and changed the FPU (FloatingPoint Unit value) for all the processes.

To Set the FPU value to dafault u can use _controlfp() function defined in "msvcrt.dll". This is a native function, to call this function in C# u will have to use .NET Runtime Interop Services. To do this add the following lines of code to your Form class

[DllImport("msvcrt.dll")]
private static extern int _controlfp(int n, int mask);
private const int _MCW_EW = 0x8001F;
private const int _EM_INVALID = 0x10;

Now call this function at the start of your form constructor

_controlfp(_MCW_EW, _EM_INVALID);

The FPU value is now set to default and you will not get any Exception in system.Drawing.dll

Comments

0 comments have been posted.