Re: [問題] 如何利用Matlab寫好的.m檔轉成C#能用的DLL
我照黑皮大大的做法下去做以後
結果出現了下面的例外訊息
System.TypeInitializationException: 'GetAA.GetAB' 的型別初始設定式發生例外狀況
。 ---> System.Runtime.InteropServices.COMException (0x8007007A): 傳遞到系統呼
叫的資料區太小。 (發生例外狀況於 HRESULT: 0x8007007A)
於 MathWorks.MATLAB.NET.Utility.MWMCR.mclCreateComponentData(Byte[]
publicData, String nameData, String rootData, Byte[] sessionData, String[]
matlabPathData, Int32 matlabPathDataCount, String[] classPathData, Int32
classPathDataCount, String[] libPathData, Int32 libPathDataCount, String[]
mcrApplicationOptions, Int32 mcrApplicationOptionCount, String[]
mcrRuntimeOptions, Int32 mcrRuntimeOptionCount, String prefDir, String
pathToComponent, String[] mcrSetWarningState, Int32 mcrSetWarningStateCount)
於 MathWorks.MATLAB.NET.Utility.MWMCR..ctor(String componentName, String
rootData, Byte[] publicEncryptionKey, Byte[] sessionEncryptionKey, String[]
matlabPathEntries, String[] classPathEntries, String[] libPathEntries,
String[] mcrApplicationOptions, String[] mcrRuntimeOptions, String prefDir,
String[] mcrSetWarningState, String componentPath, Boolean isLibrary)
於 GetAA.GetAB..cctor()
--- 內部例外狀況堆疊追蹤的結尾 ---
於 GetAA.GetAB..ctor()
於 WindowsApplication1.Form1.button1_Click(Object sender, EventArgs e) 於
D:\新增資料夾 (2)\WindowsApplication1\WindowsApplication1\Form1.cs: 行 30
請問各位大大這個狀況該怎麼解決呢:P
※ 引述《hpbrother (黑皮)》之銘言:
: matlab要寫成function的形式
: 把剛剛的dll加入參考
: 把.NET裡的Math Works…..也加入參考
: 把COM裡的Matlab Application….加入參考
: 記得 using dll和MLApp
: int xx = 2;
: IOputclass demo = new IOputclass(); //IOputclass是你的class名稱
: MathWorks.MATLAB.NET.Arrays.MWArray m = 6, n = 2; //傳入
: MathWorks.MATLAB.NET.Arrays.MWArray[] x;//輸出
: x = demo.IOput(xx, m, n);
: MessageBox.Show(x[1].ToString());
: ※ 引述《smallgun ()》之銘言:
: : 因為我用Matlab的deploytool工具把m檔轉成DLL後
: : 也把此DLL加入參考...發現不知如何寫code來呼叫它
: : 看了Matlab的範例也不太懂...
: : 麻煩各位大大幫個忙囉~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.17.20.85
討論串 (同標題文章)