Peter
Peter

Reputation: 71

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 ). As soon as I try to instantiate the ankur_dummy class, which is in a DLL generated by MatLab, it crashes. I get "VSHost.exe has stopped working"

If I do "Debug->Start without debugging" it runs just fine.

So the debugger doesn't seem to have a problem with the Matlab dll's, just the one generated.

Running 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);
    }
}

Upvotes: 1

Views: 761

Answers (1)

Peter
Peter

Reputation: 71

Ok, I've found a simple solution.

Disable the Visual Studio hosting process.

Under project settings -> Debug -> Enabled Debuggers

uncheck "Enable the visual studio hosting process"

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. He could have a different version of Visual Studio as well, not sure about that.

Upvotes: 1

Related Questions