FAQ (Frequently Asked Questions)
for .NET developers on using WSQ image library





I am using ASP.NET on Windows 2003 Server and IIS 6.0. I am writing web application which loads WSQ image library DLL, however my application fails to load DLL.

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.

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.

To download special version of "WSQ image library" with Registration utility click here

To download Microsoft Visual C# .NET 2003 sample project click here

To download Microsoft Visual Basic .NET 2003 sample project click here

Please extract the zip file, inside you will find file “WSQ_library.dll” which is a version of DLL build specially to work under ASP.NET + II6.0 environment.

This version of “WSQ image library” DLL is almost identical to standard version of DLL, only with small difference:
it does not have pop-up window of "file properties"

and it does not have "file format converter" utility

but most probably you do not need them anyway (in other words in this version of DLL all Forms and MessageBoxes are removed).

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.




My application calls the function from WSQ image library DLL. The function returns correct value, however in the next line of .NET program code my application crashes. What should I do?

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)












Copyright © 2010 Cognaxon. All rights reserved.