FAQ (Frequently Asked Questions) for .NET developers on using WSQ image library
The problem is caused by IIS 6.0.
IIS 6.0 does not support full set of Win32 API functions, including very fundamental ones like for example MessageBox or creating and showing Forms.
It is enough that MessageBox is simply present somewhere in DLL and even never used and called by your application - IIS 6.0 will fail to load such DLL.
The only solution to this problem is to remove from DLL all native Win32 API calls which IIS 6.0 fails to support and recompile DLL with all MessageBoxes and Forms removed. Cognaxon has built such ripped version of DLL which IIS 6.0 is able to load. Please contact us if you need it for your application.
Also please note that ASP.NET requires that DLL files must be located in "system32" directory/folder. As for example, under Windows XP you need to copy the file "WSQ_library.dll" to "C:\WINDOWS\system32" directory/folder.
This problem affects all Win32 DLLs which are called from .NET program. And WSQ image library is exactly Win32 DLL, so it is affected too.
It is known bug of .NET platform.
This issue is caused by thirty-part applications or controls (in our case by "WSQ image library" DLL), which change floating-point control register so floating-point exceptions like overflow are unmasked.
.NET Framework assumes that the FPU control register is set to mask floating point exceptions.
The solution is to declare function in your code
Visual Basic .NET
| |
<DllImport("msvcr70.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Auto)> _
Shared Function _controlfp(ByVal n As Integer, ByVal mask As Integer) As Integer
End Function
|
Visual C# .NET
| |
[DllImport("msvcr70.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int _controlfp(int n, int mask);
|
And after calling any function from Win32 DLL you need to reset the FPC Register (Word) to its default value as expected by .NET framework.
Program code for reseting FPC Register is
Visual Basic .NET
| |
_controlfp(&H9001F, &HFFFFF)
|
Visual C# .NET
| |
_controlfp(0x9001f, 0xfffff);
|
As a demonstration of this problem consider Visual Basic .NET code
| |
OutputPicture.Image = Bitmap.FromHbitmap(_CreateBMPFromFile(lpszDialogFileName))
'After calling function in Win32 DLL you need to reset the FPC Register (Word)
'to its default value as expected by .NET framework
_controlfp(&H9001F, &HFFFFF)
Dim Font1 As Font
Font1 = New System.Drawing.Font("Courier New", 8.25F, _
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
|
If you remove line
| |
_controlfp(&H9001F, &HFFFFF)
|
from the code, the application will crash trying to create font on line
| |
Font1 = New System.Drawing.Font("Courier New", 8.25F, _
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
|
|