Skip to main content

My codes (that were working with the 2024 version) do not work anymore with the 2025 release.
this is the error I get in the function “InitConnection()”:

Message: Could not load file or assembly 'ZemaxEngine.dll' or one of its dependencies. The dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
Source: mscorlib
HelpLink: None

Hi Luca,

You might want to try changing the directory mentioned in this post. Hopefully, it will help.

Matlab examples failing to connect to OpticStudio | Zemax Community


That part of the code works well, the error appears when I try to execute the line

app = TheConnection.CreateNewApplication()

I have exactly the same issue.

Waiting for a solution from Zemax


Hi all,

Updating MATLAB to the latest version should resolve this issue. Please try updating and let us know how it goes.

下载 MATLAB、Simulink、Stateflow 和其他 MathWorks 产品

Julia


Hi all, 
I am facing the same problem and updating to the latest Matlab (ie version R2024b) did not solve the problem. The method CreateNewApplication()results in the same error: 

Message: Could not load file or assembly 'ZemaxEngine.dll' or one of its dependencies. A dynamic link library
(DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
Source: mscorlib
HelpLink: None

FYI, I am using OpticStudio 2025.


Hi bostanem,

Would you please try the version below?  

Julia 


Hi Julia, 
Thanks a lot. It seems that I can install Update 5 (and not 4). Would that be okay?


Hi bostanem,

I just updated my Matlab to Update5, I experience no error with this version. 


Thanks Julia, this seems to fix the issue for me. I appreciate your help. 


Reply