There is a common error that can result from running 32-bit user extensions and user analyses in OpticStudio. The error may manifest in odd ways where an extension fails to open or has an unexpected user interface.
When using the ZOS-API, it will engage a dynamic-link library (DLL) called the ZOSAPI_NetHelper.dll. The function of this DLL is to help the user extension locate the installed version of OpticStudio. OpticStudio versions older than 2023 R2 suffered from an issue where the NetHelper DLL could not properly search the Windows registry if the target bit setting of the user extension did not match OpticStudio. Since OpticStudio is a 64-bit program, it might not be found if a user extension was compiled as 32-bit, which is the default for common compilers.
In short, if a user extension is compiled as 32-bit and tries to use the NetHelper to find the installation location of OpticStudio, it may fail and deliver the above error message: “OpticStudio cannot be found.” If you possess the source code and are familiar with recompiling the extension, this particular error can generally be remedied by specifying the path to the OpticStudio directory in your Program Files, as shown. However, a more robust solution is to ensure that 64-bit is the target for the compiled code (see What target bit setting should I use to compile ZOS-API extensions? | Zemax Community for more details).
initialized = ZOSAPI_NetHelper.ZOSAPI_Initializer.Initialize( OpticStudioPath );
Newer releases of OpticStudio include an updated helper DLL that should work regardless of whether running a 32- or 64-bit .NET application. However, we still recommend that the extensions run as 64-bit, unless there is a specific need for 32-bit. See (What target bit setting should I use to compile ZOS-API extensions? | Zemax Community) for more information on how to compile your code in a way that is compatible with Ansys Zemax OpticStudio.
There could be a situation where you have the latest version of OpticStudio installed, but you are still observing errors or unexpected behavior. In this case, it is possible that the NetHelper DLL was not updated correctly. The easiest way to be sure is to follow these steps:
- Uninstall ALL OpticStudio software (both Ansys and Legacy).
- Go to Documents\Zemax\License and delete the "version.log" file. (This directory may be located elsewhere depending on your Setup...OpticStudio Preferences...Folders setting.)
- Install the latest Ansys version of OpticStudio.
- When you run OpticStudio for the first time, you will be prompted to update the files in your Zemax directory. Make sure that allow files to be copied into your Zemax directory.
Important Note: We generally recommend that you only have one version of OpticStudio installed at a time. We especially recommend not having both Ansys and Legacy versions of OpticStudio installed on the same machine. By installing multiple versions, you run the risk of incorrect registry settings or old versions of the ZOS-API DLLs being used.