BenHW 0.9.0

dotnet add package BenHW --version 0.9.0
                    
NuGet\Install-Package BenHW -Version 0.9.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BenHW" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BenHW" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="BenHW" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BenHW --version 0.9.0
                    
#r "nuget: BenHW, 0.9.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BenHW@0.9.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BenHW&version=0.9.0
                    
Install as a Cake Addin
#tool nuget:?package=BenHW&version=0.9.0
                    
Install as a Cake Tool

BenHW .NET SDK

C# SDK for controlling Bentham spectroradiometer hardware.

Overview

The BenHW .NET SDK provides a modern, type-safe C# interface to the BenHW DLL for controlling Bentham Instruments hardware including monochromators, detectors, amplifiers, and other optical components.

Features

  • Multi-targeting: Supports .NET Framework 4.8 and .NET 8
  • Type-safe: Strong typing with structs for multi-value returns
  • Exception-based error handling: Automatic error detection and meaningful exceptions
  • Automatic DLL loading: Finds and loads the appropriate 32-bit or 64-bit DLL
  • IDisposable: Proper resource management with automatic DLL unloading

Installation

Via NuGet

dotnet add package BenHW

Or via Package Manager Console:

Install-Package BenHW

Manual Installation

  1. Download the SDK package
  2. Reference BenHW.dll in your project
  3. Ensure the BenHW DLLs (benhw32_cdecl.dll or benhw64.dll) are in the dlls subdirectory

Quick Start

using BenHW;

// Create instance (automatically loads DLL)
using (var hw = new BenHW.BenHW())
{
    // Build system model from configuration file
    string errorMsg = hw.BuildSystemModel("system.cfg");
    
    // Load setup attributes
    hw.LoadSetup("system.atr");
    
    // Initialize hardware
    hw.Initialise();
    
    // Select wavelength
    int settleDelay = hw.SelectWavelength(500.0);
    
    // Take a measurement
    double reading = hw.Automeasure();
    Console.WriteLine($"Reading: {reading}");
    
    // Get/Set operations
    hw.Set("mono", Tokens.MonochromatorCurrentWL, 0, 550.0);
    double wavelength = hw.Get("mono", Tokens.MonochromatorCurrentWL, 0);
    
    // Close (automatically called by Dispose)
    hw.Close();
}

Error Handling

The SDK uses exceptions for error handling. All BenHW errors throw specific exception types:

try
{
    hw.SelectWavelength(1000000.0); // Invalid wavelength
}
catch (BI_invalid_WL_Exception ex)
{
    Console.WriteLine($"Invalid wavelength: {ex.Message}");
}
catch (SdkException ex)
{
    Console.WriteLine($"SDK error: {ex.Message} (code: {ex.ErrorCode})");
}

License

Copyright (c) Bentham Instruments Ltd. All Rights Reserved.

Support

For support, contact Bentham Instruments Ltd or visit our website.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.0 124 7/28/2026
0.8.0 114 7/28/2026
0.7.0 124 7/1/2026
0.6.0 127 6/30/2026
0.5.0 134 6/17/2026
0.4.0 123 5/14/2026
0.2.0 208 2/10/2026