How to Close COM server, Coinitiliaze has not been called

조회 수: 16 (최근 30일)
Trey Moore
Trey Moore 2014년 7월 25일
답변: Gordon W 2018년 7월 2일
I am having a problem closing an actxserver which is forcing me to close Matlab to run my program more than once. I have tried several codes to close the COM server, but I cannot get it to work. Anything I'm missing?
My Code:
h=actxserver('ServerName');
...code...
I have tried putting these at the end of my code:
Quit(h) as well as h.Quit
close(h) as well as h.close
delete(h) as well as h.delete
Error Given:
Error using feval
Server Creation Failed: CoInitialize has not been called.
Error in actxserver (line 87)
h=feval(['COM.' convertedProgID], 'server', machinename, interface);
Error in MMM_V1 (line 160)
h=actxserver('ServerName');

답변 (2개)

Gordon W
Gordon W 2018년 7월 2일
In case someone is still in need of a solution, I found it here:
tl;dr: Use release(handle) for any handle that is connected to the COM server.

Image Analyst
Image Analyst 2014년 7월 25일
How about h.exit or h.Exit or h.shutdown? Or clear('h').
You need to get the commands that work with your server. Every program has different methods. I'm only familiar with Excel. Your server is not Excel is it?
  댓글 수: 4
Trey Moore
Trey Moore 2014년 7월 28일
I do not see a server process still running under the name of the server, so I am guessing that the answer is no. That said I am not super familiar with COM.
Image Analyst
Image Analyst 2014년 7월 28일
Have it up and running when you launch. Does the process list grow longer when your server launches? It must be in there. Look at the process list when the server is supposed to be running of course, not after you think you shut it down. When you do go to shut it down, the list should shrink. Try to identify which process gets instantiated and destroyed as you do this. That will be the name of the server and I think it should be the same name you used in your MATLAB application.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by