PrinterCE and "DLL Load Error"
An application that is working well with PrinterCE
SDK or PrinterCE.NetCF SDK may occasionally fail when trying to create
an instance of one of the PrinterCE components:
-
eVB apps: CreateObject fails
-
eVC apps: CoCreateInstance fails
-
C# and VB.Net apps:
Calling
the PrinterCE constructor fails with an "Invalid or incorrect
version of PrCE_NetCF.dll" error.
While rare, this situation seems to
be most often seen in apps
that use SQLCE. A check of available memory will show that there is
plenty of memory on the device. A soft-reset of the device will
usually resolve the situation, at least temporarily.
This situation is known as a
"DLL Load Error" and is due to the memory architecture design
of Windows CE. For in-depth details on this, please review the
following Microsoft documents:
Understanding Windows CE DLL Load Failures
Windows CE .NET Advanced Memory Management
(See especially "DLL Load Problem" section).
Resolving DLL
Load Error: The PrinterCE fix for a DLL load failure is
usually quite simple - make PrinterCE a global class and create the
PrinterCE instance as soon as your app starts - especially before
using SQLCE. Then use this instance every time you use PrinterCE to
print.
Note for .NetCF developers -
be sure to NOT call PrinterCE's ShutDown() function after a print job,
which would delete the global instance. You need to add KillDoc() to your "catch"
block to free up PrinterCE resources between print jobs in case of
an exception.