TX Text Control .NET for Windows Forms

Native Libraries and Architecture Mismatches

Topic

The document engine of TX Text Control is a set of native Windows libraries, one set for 32-bit and one for 64-bit processes. The .NET assemblies are the same for both, and they load the native set that matches the process. When that set is missing, belongs to the other bitness, or lacks the Visual C++ runtime it needs, the application fails as soon as the engine starts. 32-bit and 64-bit Applications explains the two sets.

The Kernel DLL File Could Not Be Found

Creating a TextControl or ServerTextControl fails with this message:

The TX Text Control kernel DLL file could not be found.

The native libraries for the bitness of the process aren't where TX Text Control looks for them. In a .NET Framework application, the files of Assembly\bin are for 32-bit processes and those of Assembly\bin64 for 64-bit processes, and all files must be in the folder of the executable. An AnyCPU application runs as a 64-bit process on 64-bit Windows, so it needs the 64-bit set there.

  1. Decide on a bitness and build for it: create x86 and x64 configurations as the next section shows, or deploy the set that matches the host of an AnyCPU application.
  2. In a .NET Framework application, copy the native libraries of Assembly\bin for x86 or Assembly\bin64 for x64 into the folder of the executable, next to the managed assemblies.
  3. In a .NET 8 or later application, publish with a target runtime, such as win-x64, so that the native libraries of that runtime are copied from the package. See Publishing .NET Applications.

The Application Runs With the Wrong Bitness

The application runs on some machines and fails on others with the message of the previous section, or it works in Visual Studio and fails when it is deployed.

An x86 build runs as a 32-bit process on 32-bit and 64-bit Windows, and an x64 build as a 64-bit process. An AnyCPU build takes the bitness of the host, so the native libraries it needs depend on the machine. The samples of TX Text Control come with x86 and x64 configurations for this reason.

  1. Create x86 and x64 configurations in the Configuration Manager, as Create x86 and x64 Configurations in Visual Studio shows.
  2. Build for one platform and deploy the native libraries of the same bitness, as x86, x64, and AnyCPU describes.

The Visual C++ Runtime Is Missing

The application fails on a machine where it wasn't developed, while all files of TX Text Control are deployed.

TX Text Control .NET for Windows Forms uses the Microsoft Visual C++ runtime file VCRUNTIME140.DLL, which not every Windows installation has.

  1. Install the Visual C++ Redistributable Packages for Visual Studio 2017 in the bitness of your application on the target machine, and include it in your installer, as Install the Runtime on the User's Machine describes.

The Files of an Earlier Version Are Deployed

After an upgrade, an installer or a deployment script that lists the files by hand fails to deploy the native libraries, or the application starts with the files of the previous version.

Since version 33.0, the native libraries txkernel.dll, txtools.dll and txic.dll have new names, which include the version like the names of the format libraries, such as tx34.dll, tx34_tls.dll and tx34_ic.dll in version 34.0. A hand-written file list doesn't follow the change.

  1. Update the file list of your installer, as An Installer Doesn't Include the Files of TX Text Control describes.

Create Returns False

ServerTextControl.Create returns false, and using the instance fails with this message:

The TXTextControl object must have been completely loaded to use this method.

Create returns false when no new window handle can be created for the instance, usually because instances that aren't disposed keep their handles until Windows' limit per process is reached. The same message appears when a member is used before Create was called at all.

  1. Call Create directly after new ServerTextControl(), and don't use the instance when it returns false.
  2. Create every ServerTextControl in a using block, so that it is disposed.
  3. Count the instances and handles of your application, as Count Instances and Handles shows.

Dispose Every ServerTextControl explains the handle limit.