locked
How to make TRACE work in native C++ code for a C# Univeral apps project

    Question

  • I am playing the real-time communication sample project.  It works as expected but writing to the Output console does not work for the C++ code.  I have tried the TRACE macro,  and also tried the Trace() function of the project. Nothing is shown in the Output console. I am using the Debug configuration and running the app in the debug mode.

    Could anyone shed some light on this?


    Hong

    Friday, March 20, 2015 4:18 PM

Answers

All replies

  • Friday, March 20, 2015 5:15 PM
  • Thanks for the response.  Here is the Trace method of the project which uses OutputDebugString:

    void Trace(DWORD dwLevel, LPCWSTR pszFormat, ...)
    {
        if (g_dwLogLevel > dwLevel)
        {
            return;
        }
        WCHAR szTextBuf[256];
        va_list args;
        va_start(args, pszFormat);
    
        StringCchVPrintf(szTextBuf, _countof(szTextBuf), pszFormat, args);
    
        OutputDebugString(szTextBuf);
    }
    It does not work. It does not generate any error either.


    Hong

    Friday, March 20, 2015 5:22 PM
  • Try a simple call without wrappers to see if it works first.
    Sunday, March 22, 2015 10:24 AM
  • Thank you.  Your tip has just made me realize that that dwLogLevel was set too high for the Trace method. 

    Hong

    Sunday, March 22, 2015 11:10 AM