Including Libraries in your Projects

The Client Tools package includes quite a bit of functionality and while it's not very large, it's generally not a good idea to include functionality that you don't use in your application. For this reason we recommend that you selectively include specific libraries in your own application, by picking and choosing what to load.

There are two sets of install issues that you need to address:

  • Binary Dependencies (.NET or Win32 DLLs)
  • FoxPro Dependencies

All components in this help file list their dependencies - both FoxPro and binary. You can also load dependencies automatically by DO <Component>.prg as components automatically (assuming they are accessible) which loads their dependencies via SET PROCEDURE or other DO <Component>.prg commands from the FoxPro path.

The Shareware version has to do DO wwClient to load all libraries at once from wwClient.app which is the only option available.

Paths for using the West Wind Client Tools

All Binary dependencies (.dll files) have to be copied into the application folder, and have to be distributed with your application. You should update these files whenever you update the library. wwIPstuff.dll, dzip.dll, dunzip.dll and zlib.dll nust be placed in the current directory the application is running in to be found. All other .NET DLLs can be loaded from the FoxPro path as they are loaded with wwDotnetBridge.LoadLibrary() which can resolve the path and implicit dependencies will load from the same location. Regardless it's recommended you put all .NET components into the same folder to avoid version conflicts and assembly not found errors.

The recommended approach for FoxPro components is to use the FoxPro path to find libraries to pull in the .prg file dependencies - preferably from a relative path to your project. To do this add:

lcWwClientToolsPath = "<wwClientInstall>\classes"
SET PATH TO (lcWwClientToolsPath)  ADDITIVE

to include the Client Tools installation folder and let FoxPro pull in libraries as needed for each DO <wwClientComponent>.prg operation.

You can reference the install's classes folder via the FoxPro path that can be set either in code as part of your application, a small SetEnvironment.prg program file (a good idea for all your app libraries and app settings!), or via a config.fpw PATH assignment on startup.

Binary Dependencies

The Client Tools includes a number of binary support files that are used by the various FoxPro libraries. The files need to be available on the FoxPro path when your application runs and need to be physically available on disk when your application runs.

In other words you have to distribute these files, and they need to be kept up to do date and in sync with the FoxPro files that use them.

Core Components - always required

  • wwIpStuff.dll - a Win32 helper library used for many support functions
    This is the base library that provides a number of core helpers and is used by most tools in this library.

  • wwDotnetBridge.dll - .NET library that provides Interop for FoxPro
    In addition to several components that use .NET (wwSmtp, wwJsonSerializer, wwFtpClient/wwSFtpClient etc.), many of the support functions in wwUtils and wwApi also rely on wwDotnetBridge.

Feature Specific .NET Components

  • Newtonsoft.Json.dll - JSON Parsing used for JSON Serialization and REST Services
  • FluentFtp.dll - Used for wwFtpClient and FTP/FTPS functionality
  • Renci.SshNet.dll - Used for wwSFtpClient and SFTP functionality
  • Markdig.dll - Used for markdown parsing in the MarkdownParser class
  • dzip32/dunzip32/zlib1.dll - Zip functions other than ZipFolder()\UnzipFolder()

Make sure that you copy these dependencies with your application when you deploy it.

It's recommended that you create a small FoxPro program that copies the latest versions of the files you need into your project folder for distribution (or a build folder if you do a proper install).

FoxPro Library Dependencies

FoxPro depdendencies are referenced exclusively from PRG files and can be compiled into your application, so you only need to make sure they are accessible during development.

There are a couple of ways you can include features:

  • Reference the Library from the Install Folder
  • Copy files and dependencies into your project

Reference Libraries from the Install Folder

This is the recommended way to handle dependencies in your own projects. Rather than copying files you need into your project folder you make sure your FoxPro path includes a reference to the Client Tools install folders. You need to add two folders (depending on the install location)

SET PATH TO "c:\wwclient\classes" ADDITIVE
SET PATH TO "c:\wwclient" ADDITIVE

A variation of this is to create a project specific copy of the Client Tools alongside your application. That way you can use a fixed path with a version that remains fixed if needed or can be updated wholesale from an Client Tools update. You can also check that version into source control.

While this works fine, it's not recommended as you'll have to keep the files in sync with a new versions. It's simply better to reference the original source files.

You can set the path in your config.fpw or use an environment or application startup script to set the paths. I like to have a _setenv.prg file that includes the above.

Once you do this you can now access the libraries directly without any pathing:

*** load with dependencies
DO wwHttp

*** or explicitly
SET PROCEDURE TO wwHttp ADDITIVE

Your project will then automatically pull in the PRG files from the path referenced locations automatically.

Shareware Version works differently

If you're using the shareware version, there are no source files, so you can't load individual libraries. Instead you have to do:

*** Loads all included libs from wwClient.app 
*** and does SET PROCEDURE TO on all of them
DO wwClient   

You can also do this in the non-shareware version which loads the individual libraries from their respective PRG file, but it's still recommended that you only include what you use to minimize size impact in your application.

Don't Copy FoxPro Source Files into your Project

Alternately, you can add the files that you need directly to your project. This ensures you get a specific snapshot version of files, but on the downside it's more complicated to keep files updated as newer versions of the Client Tools are installed.

As a compromise you can copy the entire wwClient folder into your project and add a path to the classes and root folder to find components. This ties a version specific version that holds all dependencies.

Summary

One way or another the binary dependencies have to be explicitly managed - preferrably with a small copy/install build script - to ensure the correct version of the files are installed with your projects. FoxPro dependencies get compiled into your project regardless of how you reference them, but you need to choose between local copies of the files and manually managing the file versions, or directly referencing the West Wind Client library from its install folder.

See also