作者mars0130 (贵贵 XD)
看板C_Sharp
标题Re: [问题] 如何利用Matlab写好的.m档转成C#能用的DLL
时间Fri Apr 17 10:43:38 2009
我照黑皮大大的做法下去做以後
结果出现了下面的例外讯息
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