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
採用された回答
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
