IR
irwinrodriguez.dev
Back to docs

FoxBridge

FoxBridge brings the .NET ecosystem into Visual FoxPro. You instantiate any .NET class, call its methods, read and write properties, work with generic collections (List<T>, Dictionary<K,V>), invoke static members and consume async/await, all with the dot syntax of your usual VFP code. No COM, and nothing to register.

In this section

  • Installation: The files to copy, the .NET runtime and activating the license.
  • Quick Start: Your first .NET object from VFP in under five minutes.
  • Examples: Twenty progressive examples, from StringBuilder to HttpClient and async/await.
  • API Reference: The FoxBridge class and the collection proxies, method by method.

How it works

Two layers and a single class. FoxBridge.prg is the API you see from VFP; underneath, x86\FoxBridgeNE.dll starts the .NET runtime and forwards the calls, leaning on FoxBridge.dll, Nexum.dll and the two .json files that sit beside it. All five files in that subfolder travel together.

Activate the bridge and create a .NET object
* Initialize and activate (the two lines go together)
loBridge = NEWOBJECT("FoxBridge", "FoxBridge.prg")
IF !loBridge.Activate(lcJwt)
    ? loBridge.GetLastError()
    RETURN
ENDIF

* And from here on, .NET with dot syntax
loSB = loBridge.Create("System.Text.StringBuilder", "Hello ")
loSB.Append("from .NET!")
? loSB.ToString()   && "Hello from .NET!"
The license is always required In the IDE and in the compiled EXE alike. It is a JWT that you hand to loBridge.Activate() at start-up, and the check sits at the start of all fifty entry points of the engine: without activating, not even a StringBuilder. If maintenance has expired the product keeps working; what expires is the right to new versions.

What you get

  • Instantiation of any .NET type, with up to ten constructor parameters
  • Generic collections: List<T>, Dictionary<K,V> and arrays, 1-based like VFP
  • Static members: class methods, properties and fields, through Static()
  • Enums read by name from the static proxy (loFileMode.Create), instead of remembering the number
  • Automatic overload resolution and type coercion from VFP to .NET
  • async/await transparently: the task is awaited and returns its result
  • Loading your own compiled DLLs, with LoadAssembly()
  • Nine ready-made satellites and a tutorial with ClosedXML and iText, inside the package itself (the table below)

The nine satellites

They ship inside the package, under Satellites\, and they are VFP .prg files you can read and change: each wraps a slice of .NET in FoxPro-named functions, so you do not write Create() by hand. Load one with SET PROCEDURE TO fb_http ADDITIVE and hand them the bridge once, with FB_SET_INSTANCE(loBridge), which they all share.

SatelliteWhat it wraps
fb_httpRequests with HttpClient: GET, POST, PUT and DELETE, the status code with HEAD, and download to a file.
fb_jsonRead JSON by dot-path on top of System.Text.Json, validate and pretty-print it; and build it with plain-VFP functions.
fb_cryptoText and file hashes, HMAC, AES (text and files), RSA (keys, encrypt, sign and verify), secure random values and Base64.
fb_emailSMTP mail with SmtpClient: set the server and the sender, send, and validate an address.
fb_ioZIP (create, extract, add and list), files (copy, move, delete, size), folders and paths.
fb_processLaunch processes and collect their exit code or what they print, list and kill them, open a file or a URL with its program, and environment variables.
fb_dialogsMessage box, open and save file, folder picker and the clipboard. It is the only one that needs the .NET Desktop Runtime, because it uses WinForms.
fb_aixlRuns AIXL scripts over VFP cursors. It needs the AIXL DLL and license, which are not on sale today.
fb_aixl_easyThe same AIXL layer as one-line functions, such as AIXL_CLASSIFY(). Same requirement as fb_aixl.

Requirements

ComponentRequirement
Visual FoxProVFP 9.0 SP2 (x86). The package also ships x64\ for 64-bit VFP Advanced
WindowsWindows 10 or 11
.NETRuntime 8.0 or later, in the architecture of the process: with VFP 9, the x86 one
COMNone. No registration, no installer and nothing written to the Windows registry