How can I solve the error of Aspen Hysys case opening "Invoke Error, Dispatch Exception: Access is denied."

50 次查看(过去 30 天)
Dear,
I am using MATLAB 2016a and Aspen HYSYS V9. I am trying to connect between two program and encounter the error as following:
>> hysys=actxserver('Hysys.Application')
hysys =
COM.Hysys_Application
>> simcase=hysys.SimulationCases.Open([cd,'\an.hsc']);
Error using Interface.HYSYS_9_Type_Library.SimulationCases/Open
Invoke Error, Dispatch Exception: Access is denied.
I tried to run MATLAB as Administrator but the result was still the same. I put the an.hsc file in MATLAB path.
Please kindly help me solve this error. Thank you very much for your help.
  2 个评论
Zain Javed
Zain Javed 2020-5-26
Hi! If you get your answer so please help the people like me so we can make this world a better place with our projects.
Thanks
Hossein Hanzali
Hossein Hanzali 2023-12-8
I have the same problem, the .m file and .hsc files are in the same folder. I tried a lot but not solved. please return the answer to me if the problem solved

请先登录,再进行评论。

回答(3 个)

Rasel Ahmed
Rasel Ahmed 2020-8-26
Put both files, Hysys simulation case (.hsc) & the following matlab script (.m) in the same folder. Matlab Code, please modify simulation name ("Distill_Example.hsc") accondingly:
Hysys=actxserver('Hysys.Application.V10.0'); %COM Technology
[stat,mess]=fileattrib; %getting actual folder name
simcase = Hysys.SimulationCases.Open([mess.Name '\Distill_Example.hsc']); %Opening HYSYS Simulation (Distill_Example.hsc)
simcase.invoke('Activate'); %Opening HYSYS Simulation (Distill_Example.hsc)
Typically, "Error using interface" can be generated due to lack of Hysys License, therefore the program cannot initialize.
If the error persists, you can send me the simulation and I will try to make the Matlab-Sim Hysys connection.
Regards,
Andrés Abril
for details discussion, please follow this link.

Francesco Catena
Francesco Catena 2022-9-28
Hi,
The .m file and the .hsc file have to be in the same folder. Then you can proceed as follow:
Hysys = actxserver('Hysys.Application.V11.0');
FileNamePath = 'File_name';
Simulation = Hysys.SimulationCases.Open([cd,strcat('\',FileNamePath,'.hsc')]);
Simulation.Visible = true;
Components = Simulation.Flowsheet.Operations;
Streams = Simulation.Flowsheet.MaterialStreams;
Fluxes = Simulation.Flowsheet.EnergyStreams;
Best regards,
Francesco

용
2023-11-20
Same Folder is solution

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by