简体   繁体   English

调试Matlab生成的DLL时C#VS2012 vshost.exe崩溃

[英]C# VS2012 vshost.exe crashes when debugging Matlab generated DLL

I'm able to run the visual studio debugger and debug the first part of this program ( using the MWNumericArray ). 我可以运行Visual Studio调试器并调试该程序的第一部分(使用MWNumericArray )。 As soon as I try to instantiate the ankur_dummy class, which is in a DLL generated by MatLab, it crashes. 一旦我尝试实例化由MatLab生成的DLLankur_dummy类,它将崩溃。 I get " VSHost.exe has stopped working " 我收到“ VSHost.exe停止工作

If I do " Debug->Start without debugging " it runs just fine. 如果我执行“ Debug-> Start而没有调试 ”,它将运行正常。

So the debugger doesn't seem to have a problem with the Matlab dll 's, just the one generated. 因此,调试器似乎对Matlab dll没有问题,只是生成的一个。

Running MCR 7.15 X64 运行MCR 7.15 X64

Any ideas? 有任何想法吗?

static void Main(string[] args)
{
    try
    {
        double[,] testDblArr = new double[2,5];

        testDblArr[0,0] = 1;
        testDblArr[0,1] = 2;
        testDblArr[0,2] = 3;
        testDblArr[0,3] = 4;
        testDblArr[0,4] = 5;
        testDblArr[1,0] = 1.1;
        testDblArr[1,1] = 1.2;
        testDblArr[1,2] = 1.3;
        testDblArr[1,3] = 1.4;
        testDblArr[1,4] = 1.5;

        MWNumericArray testArr = new MWNumericArray( testDblArr );

        DisplayNumericArrary(testArr);

        ankur_dummy_2011.ankur_dummy test = new ankur_dummy();

        MathWorks.MATLAB.NET.Arrays.MWArray arr = test.dummy_function();

        MWNumericArray nArr = arr as MWNumericArray;

        if (nArr == null)
        {
            System.Console.WriteLine("Not a NumericArrary!");
            return;
        }

        DisplayNumericArrary(nArr);

        arr.Dispose();
        testArr.Dispose();

        System.Console.WriteLine("Done");
        System.Console.ReadKey();
    }
    catch (Exception ex)
    {
        System.Console.WriteLine("Ex = ({0})", ex);
    }
}

Ok, I've found a simple solution. 好的,我找到了一个简单的解决方案。

Disable the Visual Studio hosting process. 禁用Visual Studio托管过程。

Under project settings -> Debug -> Enabled Debuggers 在项目设置下->调试->启用的调试器

uncheck "Enable the visual studio hosting process" 取消选中“启用Visual Studio托管过程”

I will note that on another machine ( the person who created the DLL in fact ), running Win7 versus my Win8.1, and having MatLab installed ( not just the MCR ), he was able to debug fine even with the visual studio hosting process enabled. 我会注意到,在另一台计算机上(实际上是创建DLL的人),运行Win7与Win8.1并安装了MatLab(不仅是MCR),即使使用Visual Studio托管过程,他也可以进行调试。启用。 He could have a different version of Visual Studio as well, not sure about that. 他也可能拥有不同版本的Visual Studio,对此不确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM