.NET Wrapper for the OxygenBasic Compiler
Host OxygenBasic scripts from .NET — resolve include paths, share memory with the host,
compile with O2Basic, and execute in one clean API surface.
Run()High-level API: InitHost → Pathcall → O2Basic → Exec in a single call with OxygenHostOptions.
Resolve %app_includepath% from the host so scripts can include your .inc files safely.
Pin host variables and let Oxygen scripts read/write them — ideal for counters, buffers, and interop.
Call InitHost, Pathcall, Varcall, O2Basic, Exec, Errno yourself when you need finer control.
Throws OxygenException on compile/runtime errors, or set ThrowOnError = false and inspect OxygenRunResult.
Ships oxygen.dll (x86) / oxygen64.dll (x64) with runtime DllImport resolver. Install and go.
High-level host flow and core engine calls
Since 1.0.8: O2Basic, Exec, Buf, Lib, Link, Eval return IntPtr — compare with IntPtr.Zero, not > 0.
Hosted script with include path and optional variable resolver
OxygenRunResult result = Oxygenbasic.Run(script, new OxygenHostOptions
{
IncludeRoot = @"Sample\inc",
VarResolver = name => /* optional host variable lookup */
});
Oxygenbasic.InitHost();
Oxygenbasic.Pathcall(path => /* resolve %app_includepath% to Sample\inc */);
Oxygenbasic.Varcall(name => /* optional host variable lookup */);
// Script uses: includepath "%app_includepath%" / include "math_helpers.inc"
Oxygenbasic.O2Basic(script);
if (Oxygenbasic.Errno() == 0)
{
Oxygenbasic.Exec();
}
Samples: Sample\hosted_demo.txt, Sample\inc\math_helpers.inc, Sample\test_fib.txt
A 64-bit / AnyCPU process throws PlatformNotSupportedException instead of loading oxygen64.dll (DllMain AV). Prefer x86. Override with OXYGENBASIC_TRY_X64=1 only if you have a fixed native DLL.
oxygen.dll is global to the process (single-threaded use). Abst() cannot be undone. See docs/oxygen-process-state.md.
O2Basic, Exec, Buf, Lib, Link, Eval now return IntPtr. Compare with IntPtr.Zero. See CHANGELOG.md.
x86: build + test (net8/9/10) + hosted example. x64: build only (native tests skipped). See docs/oxygen64-x64-runtime.md.
NuGet install · environment · examples
Install-Package OxygenBasic.NET
# or
dotnet add package OxygenBasic.NET
# See OxygenBasic.Example
# hosted_demo · include path · shared memory
# test_fib · simple Fibonacci script
Requirements
Windows 10+ · OxygenBasic 0.90 · .NET 8 / 9 / 10 (Windows) · prefer x86 · ships oxygen.dll (x86) / oxygen64.dll (x64)
Install the package, host a script with include paths and shared memory, and run it in a few lines of C#.