MATLAB: Is the ASP application unable to start MATLAB 7.6 (R2008a) as a COM Automation server

MATLAB

I receive an error when I try to use MATLAB as an Automation server from my ASP code.
The VB Code inside my ASP application:
Dim Matlab As MLApp.MLApp
Matlab = New MLApp.MLApp
Matlab.Execute("plot([0 18], [7 23])")
Matlab.Execute("enableservice('automationserver',true)")
I receive the following error:
Page_Error
Retrieving the COM class factory for component with CLSID
{491B6189-7E9D-43F4-A7DE-C062DF7B326E} failed due to the following
error: 80070005

Best Answer

Ensure that MATLAB can be started as a COM Automation server by first executing the following from within a MATLAB session:
>>h = actxserver('Matlab.Application')
h =
COM.Matlab_Application
>> h.Execute('plot(1:10)')
This should display a linear plot obtained from the COM Automation server. If this fails, please ensure that MATLAB is registered by executing the following at the MATLAB command window.
>>!matlab /regserver
This process would register MATLAB as a COM server and also bring up a new session of MATLAB which you could then safely exit.
Once the above is successful, the ASPNET account should be given access to invoke MATLAB. This can be achieved by:
1. Open DCOMCNFG from the command prompt
2. Click on Component Services, expand to Computers/My Computer/DCOM Config.
3. Right click on Matlab.Application (The version number may appear within () as (Version 7.6)
4. Choose properties
5. Click on the Security Tab
6. Please choose the Customize radio button, then click on the Edit button
7. Please add access to the ASPNET account
You might have to restart the machine for these settings to take effect.