COM generic components and mclInitializeApplication of MatlabRuntime
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
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
채택된 답변
Kaustubha Govind
2012년 6월 8일
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
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.
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?
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.
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?
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.
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.
Kaustubha, I'm afraid my compiler version does not provide such API function: I have r2007b :-( As of which version is this function available?
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?
HI Kaustubha, I'm also running out of ideas. Thanks though for the support ;-) I'll see whether I contact Tech support.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 COM Component Integration에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)
