matlab与c#混合编程问题

weizhiyong_222 2008-07-04 03:21:49
最近做一个matlab与c#混合编程,解决非线性整数规划问题。
遇到如下问题:
制作完.net组件(.dll文件)后,在c#中进行调用。编译正常通过,运行时出现错误:
未处理 System.TypeInitializationException
Message="“test3.factor”的类型初始值设定项引发异常。"
Source="test3"
TypeName="test3.factor"
innerException:{"传递给系统调用的数据区域太小。 (异常来自 HRESULT:0x8007007A)"}
StackTrace:
在 test3.factor..ctor()
在 matlab与c_sharp.Form1.Form1_Load(Object sender, EventArgs e) 位置 F:\矿山卡车调度\matlab与c sharp\matlab与c sharp\Form1.cs:行号 21
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.WmShowWindow(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WmShowWindow(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 matlab与c_sharp.Program.Main() 位置 F:\矿山卡车调度\matlab与c sharp\matlab与c sharp\Program.cs:行号 17
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()

我制作dll的过程:打开deploytool\新建工程\重命名类\添加.m文件\build
...全文
492 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
他来自江湖 2008-09-30
  • 打赏
  • 举报
回复
正在学习,发现matlab 的不同版本差异比较大哈!
weizhiyong_222 2008-07-07
  • 打赏
  • 举报
回复
做成com组件就没有问题,我都晕了
不过对我来说做成.net组件和com组件没什么区别
所以 结贴了
crazyfriend 2008-07-04
  • 打赏
  • 举报
回复
好强大!
wenbin 2008-07-04
  • 打赏
  • 举报
回复
C++可以与matlab混合
C#没弄过。。矿山卡车,2003年数学建模?
好熟悉的字眼
zjh222 2008-07-04
  • 打赏
  • 举报
回复
C#有那么强大吗、??

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧