C# Library Loader
The C# API for HOOPS Exchange simplifies loading and initializing the required binaries, providing streamlined access to its functionality.
This guide explains how to use the Library
class to set up HOOPS Exchange for your applications.
using TS3D.Exchange;
static void Main(string[] args)
{
// Load and initialize the library
Library.Initialize(HOOPS_LICENSE.KEY, PATH_TO_A3DLIBS_DIR);
// HOOPS Exchange ready to use!
// Terminate HOOPS Exchange
Library.Free();
}
#define INITIALIZE_A3D_API
#include <A3DSDKIncludes.h>
#include <hoops_license.h>
int main(int argc, char* argv[])
{
// Load the library
A3DSDKLoadLibraryA(PATH_TO_A3DLIBS_DIR);
// Initialize HOOPS Exchange
A3DLicPutUnifiedLicense(HOOPS_LICENSE);
A3DDllInitialize(A3D_DLL_MAJORVERSION, A3D_DLL_MINORVERSION);
// HOOPS Exchange ready to use!
// Dispose HOOPS Exchange
A3DDllTerminate();
// Unload the library
A3DSDKUnloadLibrary();
return EXIT_SUCCESS;
}
Initializing
The Initialize
method of the Library
class handles the entire process of loading and initializing the HOOPS Exchange binaries.
Here’s its signature:
static public void Initialize(string hoopsLicense, string binFolder);
The function performs the following:
Load Binaries: It dynamically loads the required binaries into memory. The path to these binaries is provided via the
binFolder
parameter.Bind Functions: Once the binaries are loaded, all HOOPS Exchange API functions from the
Direct.API
namespace are mapped to C# delegates.License Verification and Initialization: The
Initialize
method automatically invokes the following functions: -A3DLicPutUnifiedLicense()
to verify the provided license. -A3DDllInitialize()
to initialize the HOOPS Exchange library.Error Handling: If any step fails, an
InitializationException
is thrown with a detailed error message.
Parameter Details
License Information
The hoopsLicense
parameter expects a valid license string.
If you’ve followed the environment setup tutorial, this license is available as the HOOPS_LICENSE.KEY
constant in the hoops_license.cs file.
Binary Folder
The binFolder
parameter is a string specifying the directory containing the HOOPS Exchange binaries.
Ensure this folder contains the appropriate binary for your platform:
Windows:
A3DLIBS.dll
macOS:
libA3DLIBS.dylib
Linux:
libA3DLIBS.so
Disposing
To clean up and release resources, call the Library.Free()
method when HOOPS Exchange is no longer needed.
This effectively calls A3DDllTerminate()
before releasing HOOPS Exchange binary from memory.
Full Example Usage
using TS3D.Exchange;
static void Main(string[] args)
{
try
{
// Initialize the library
Library.Initialize(HOOPS_LICENSE.KEY, PATH_TO_A3DLIBS_DIR);
// Perform HOOPS Exchange operations here
}
catch (Library.InitializationException ex)
{
Console.WriteLine($"Initialization failed: {ex.Message}");
}
finally
{
// Ensure proper cleanup
Library.Free();
}
}