Debugging a project that uses C++ and C# projects in Visual Studio

55 views Asked by At

I'm currently using a project that uses several C# and C++ projects. I have a test project (in C#) I'm using to test some functionality - I have several print statements to help me debug issues. All of the print statements in my C# files appear in the console window, but all printf lines in my C++ projects do now show up. I'm unsure if this is even possible. If not, how do you go about viewing any print statements you place inside C++ files?

Here's a watered down version of my test project function flow:

static void hyperSlabTest()
{
    Console.WriteLine("Hyperslab test.");
    double[,,] hyperslab = sourceFile.GetHyperslab(rowStart, columnStart, x, y);
} 

This connects to this:

public double[,,] GetHyperslab(int rowStart, int columnStart, xWidth, yHeight)
{
     Console.WriteLine("GetHyperslab entered.");

     try{
          IntPtr ptr = FileAccess.getPingDataHyperslab(rowStart, columnStart, xWidth, yWidth);
     }
     catch(Exception ex)
     {
          Console.WriteLine("Error getting hyperslab.", ex);
     }
}

which connects to this:

[DllImport("HDF.Test.dll")]
public static extern IntPtr getDataHyperslab(
     [In] int rowStart,
     [In] int columnStart,
     [In] int xWidth;
     [In] int yWidth;
);

which finally calls this function in my C++ code (this function is also defined in my header file):

TEST_DLL void* getDataHyperslab(int& rowStart, int& columnStart, int& xWidth, int& yWidth)
{
     printf("Getting hyperslab...");

     // stuff....
}

When I run the test project, everything in the C# files runs fine and their print statements show up in the console window that appears, however, the printf line in my C++ file never shows. I've tried adding a breakpoint on that line in Visual Studio but that didn't help either. Any ideas?

0

There are 0 answers