In Visual Studio, the configuration manager can be used to specify the platform the code should be compiled for. Possible platforms are x86, x64 and AnyCPU. Due to fact that TX Text Control provides two different sets of assemblies specifically designed for 32bit and 64bit, AnyCPU can't be used out-of-the-box.

At the recent conference BASTA!, I discussed this topic with one of our users at our booth. Thanks Ramon Kania for the input! He suggested a solution that allows you to compile and deploy applications built as AnyCPU.

The core idea is to change the path of the assemblies dynamically. The AppDomain.AssemblyResolve event can be used to load the assemblies from another path. Thus enables you to compile your application as AnyCPU. You only need to distribute both sets of DLLs and depending on the current platform, the proper assemblies are loaded.

public static void HookOnCurrentAppDomain()

public static void HookOnAppDomain(AppDomain appDomainToHookOn)
    appDomainToHookOn.AssemblyResolve += AppDomain_AssemblyResolve;

private static Assembly AppDomain_AssemblyResolve(object sender,
    ResolveEventArgs args)
    return (args.Name.StartsWith("TXTextControl") ||
        args.Name.StartsWith("TXDocumentServer")) &&
               ? LoadAssembly(args)
               : null;

private static Assembly LoadAssembly(ResolveEventArgs args)
    return Assembly.LoadFrom(Path.Combine(
        IntPtr.Size == 8 ? FolderNameX64 : FolderNameX86,
        string.Concat(args.Name.Split(',')[0], ".dll")));


IntPtr.Size is a very clean way of detecting the platform. The value of this property is 4 on a 32-bit platform, and 8 on a 64-bit platform.

In the following sample application, the TX Text Control distributables must simply be copied into two different folders: x86 for the 32-bit files and x64 for the 64-bit files.

You can download a very basic example of this elegant solution here: