How to Close COM server, Coinitiliaze has not been called
29 views (last 30 days)
Show older comments
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');
0 Comments
Answers (2)
Gordon W
on 2 Jul 2018
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.
0 Comments
Image Analyst
on 25 Jul 2014
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 Comments
Image Analyst
on 28 Jul 2014
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.
See Also
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!