诊断消息
下表显示了您可能会遇到的诊断消息、消息的可能原因以及建议的解决方案。
有关一些诊断消息的信息请参阅下表。
诊断消息和建议的解决方案
消息 | 可能的原因 | 建议的解决方案 |
---|---|---|
LoadLibrary(" | 从 DOS 提示符注册工程 DLL 时可能会收到此错误消息。如果 MATLAB® Runtime 不在系统路径上,则可能会出现这种情况。 | 在安装了 MATLAB 的系统上, 在安装了 MATLAB 运行时的系统上,请确保 ( |
Mathworks.MATLAB.NET. | 您可能需要在 Visual Studio® 工程中引用 | 添加对位于 |
Error in | 这通常是由于 |
|
Error in VBAProject: ActiveX component can't create object. |
| 如果 DLL 未注册,
( |
object ref not set to instance of an object | 当调用尚未实例化的对象时,会发生这种情况 | 实例化对象。 |
Error in VBAProject: Automation error The specified module could not be found. | 如果 MATLAB 不在系统路径上,通常会发生这种情况。 | 在已安装 MATLAB 的系统中,请确保 |
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application. | 当 ASP.NET 代码尝试调出对话框时会出现此警告。 发生这种情况的原因是 | 通过执行以下操作来解决此问题:
|
使用 mstack Trace 增强错误诊断
使用此增强的诊断功能来排除 MATLAB 代码执行期间专门发生的问题。
要实现此功能,请使用 .NET 异常处理来调用 .NET 应用程序内部的 MATLAB 函数,如下 try-catch 代码模块所示:
try { Magic magic = new Magic(); magic.callmakeerror(); } catch(Exception ex) { Console.WriteLine("Error: {0}", exception); }
发生错误时,MATLAB 代码堆栈跟踪会在 Microsoft® .NET 应用程序堆栈跟踪之前打印,如下所示:
... MATLAB code Stack Trace ... at file C:\work\MagicDemoCSharpApp\bin\Debug\ CalldmakeerrComp_mcr\compiler\g388611\ca thy\MagicDemoComp\dmakeerror.m,name dmakeerror_error2,line at 14. at file C:\work\MagicDemoCSharpApp\bin\Debug\ CalldmakeerrComp_mcr\compiler\work\MagicDemoComp\dmakeerror.m,name dmakeerror_error1,line at 11. at file C:\work\MagicDemoCSharpApp\bin\Debug\ CalldmakeerrComp_mcr\compiler\work\MagicDemoComp\dmakeerror.m,name dmakeerror,line at 4. at file C:\work\MagicDemoCSharpApp\bin\Debug\ CalldmakeerrComp_mcr\compiler\work\MagicDemoComp\calldmakeerror.m,name calldmakeerror,line at 2. ... .Application Stack Trace ... at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction (String functionName, Int32 numArgsOut, Int 32 numArgsIn, MWArray[] argsIn) at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction (Int32 numArgsOut, String functionName, MWA rray[] argsIn) at CalldmakeerrComp.Calldmakeerr.calldmakeerror() in C:\work\MagicDemoComp\src\ Calldmakeerr.cs:line 140 at MathWorks.Demo.MagicSquareApp.MagicDemoApp.Main(String[] args) in C:\work\Ma gicDemoCSharpApp\MagicDemoApp.cs:line 52