COM generic components and mclInitializeApplication of MatlabRuntime
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
I have a set of generic COM components generated with the Deployment tool, and I would like to know whether I can include in these the functionality to (De)initialize the MatlabRuntime. I've seen some examples in the documentation about mclInitializeApplication but those apply to a Shared Library, which I know is a different deployment mean. Can you please refer me to some examples/information that clarifies how can I (De)Initialize the Matlab ruintime within a Generic COM component .dll? Thanks in advance
Accepted Answer
Kaustubha Govind
on 8 Jun 2012
0 votes
I'm assuming you use MATLAB Builder NE to generate the COM component? I haven't done this myself, but looking at the programming example here, it seems like the MCR (MATLAB Compiler Runtime) is automatically (un)initialized when the component is (un)initialized.
9 Comments
orlando
on 14 Jun 2012
Hi Kaustubha,
The example you mention on the link above -if I'm not mistaken- shows how to 'call a COM object in a Visual C++ program' . However, at the moment I have a number of COM dll files made with Matlab's deployment tool that are occassionally crashing during the call to Matlab routines. Our suspicion is that the Matlab runtime is not properly Unitialized last time we called Matlab code. Is there a way/tool that could help us to determine what could be the reason of the crash within the Matlab-generated .dll? Thanks in advance.
Kaustubha Govind
on 14 Jun 2012
Orlando: Yes, the example is for calling a COM object generated using MATLAB Builder NE (which is one of the products that generates COM objects from MATLAB, the other being MATLAB Builder EX I think).
Regarding the crash - I wonder if it is actually an error in the deployed MATLAB code? I don't have experience with this, but do you have some kind of standard output available so that error messages can be displayed?
orlando
on 19 Jun 2012
Hi Kaustubha,
I'm busy trying to reproduce the fault so that I can show you the corresponding output. In the mean time, I want to ask you whether using the (de) initialize ML functions can be combined with COM, i.e.
mclInitializeApplication();
//here goes my COM code
mclTerminateApplication();
Because I've seen the following output running a program with the above features -using the COM example from the documentation:
>> !matlab_com_example.exe (Visual C++ .NET 2003)
'Attempt to terminate while inhibit-shutdown is active
ML runtime successfully initialized .. The input values were 7.3 and 1946.
The output of feeding the inputs into the adddoubles method is 1953.3.
Failed to de-initialize ML runtime'
>> !matlab_com_example.exe (Visual C++ .NET 2005)
'ML runtime successfully initialized .. Attempt to terminate while inhibit-shutdown is active'
Thanks in advance,
Orlando.
Kaustubha Govind
on 21 Jun 2012
Orlando: I've not done this before, but from the example in the documentation that I cited before, it looks like you should not need to call mclInitializeApplication and mclTerminateApplication at all. What happens if you remove both calls in your code?
orlando
on 25 Jun 2012
HI Kaustubha,
The code without the mcl* functions does behave normally. What I've tried to find out is whether these functions could be combined with COM code. Currently my problem is that every now and then the code that uses the COM .dlls crashes and I suspect that it happens because a previous instance of the .dll stays in memory next time the same client code (in this case a test) runs.
With the mcl* functions I wanted test whether the previously loaded .dlls would be correctly removed before my test code runs again.
Kaustubha Govind
on 25 Jun 2012
I that the mclInitializeApplication and mclTerminateApplication are already combined into the COM components initialize/terminate methods. They are automatically called when you initialize/terminate your component. You should probably use mclIsMCRInitialized if you just need to query if the MCR was terminated properly in the previous run.
orlando
on 28 Jun 2012
Kaustubha, I'm afraid my compiler version does not provide such API function: I have r2007b :-( As of which version is this function available?
Kaustubha Govind
on 29 Jun 2012
Oh no. Sorry to hear that. Not sure when it was introduced, but the documentation is here: http://www.mathworks.com/help/releases/R2011b/toolbox/compiler/f12-999353.html#br2jauc-39
I'm out of ideas at this point. Perhaps you could try contacting MathWorks Tech Support for your issue?
orlando
on 11 Jul 2012
HI Kaustubha, I'm also running out of ideas. Thanks though for the support ;-) I'll see whether I contact Tech support.
More Answers (0)
Categories
Find more on COM Component Integration in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)