Link to home
Start Free TrialLog in
Avatar of lcha
lchaFlag for United States of America

asked on

Visual Studio 2008 debug.print not displaying output to immediate window

Hello,

I am trying to debug visual basic .net code using Visual Studio 2008.   The project is set up in configuration mode as "debug".  

I have a try and catch statement in the code.  When I run the code (f8), it errors out midway and goes to the Catch statement but it skips over the debug.print statement and nothing diplays in immediate window.   I can put a debug.print anywhere in the code and it's just gets skipped over.

Please advise any insight for what the problem could be.   Thanks!


Catch ex As Exception
            Debug.Print(ex.Message)

        Finally
            objWriter.WriteLine("Finishing Process at " & TimeOfDay)
            objWriter.Flush()
            objWriter.Close()
            objWriter = Nothing

        End Try
    End Sub

The immediate window is showing:
Step into: Stepping over non-user code 'System.ComponentModel.Design.RuntimeLicenseContext.GetLocalPath'
Step into: Stepping over non-user code 'System.ComponentModel.Design.RuntimeLicenseContext.GetSavedLicenseKey'
Step into: Stepping over non-user code 'System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo'
Step into: Stepping over non-user code 'System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo'
Step into: Stepping over non-user code 'System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo'
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.ProjectData.ClearProjectError'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.DateAndTime.TimeOfDay.get'
Step into: Stepping over non-user code 'System.IO.StreamWriter.Flush'
Step into: Stepping over non-user code 'System.IO.StreamWriter.Close'
Step into: Stepping over non-user code 'Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly'
Step into: Stepping over non-user code 'System.Threading.ExecutionContext.Run'

Open in new window

Avatar of shadow77
shadow77

Are you building a Release version instead of a Debug version?

What is F8?

Avatar of lcha

ASKER

I believe it release version ... unless I don't properly understand how to verify it.   See the screenshot for the configuration mgr.
F8 is the button I click to begin stepping thru the code line by line.
configmgr.png
See where it says "Active solution configuration"?  That says "Debug", which is what you want.

Which language are you using?  Which version of Visual Studio (year?, Express?)?
Avatar of lcha

ASKER

visual studio 2008 Professional Edition
From the Tools menu, choose Options.
Click on Debugging in the left panel. Click General.
Scroll down. Is "Redirect all Output Window text to the Intermediate Window" checked?
Or choose "Output" from the View menu and look at the end of the Output tab.
Avatar of lcha

ASKER

Is "Redirect all Output Window text to the Intermediate Window" checked?
- this is checked

The "View" menu doesn't have an option for "Output"
- I see output if I go to Debug --> Windows ---> Output... if I click here though the window is empty.

I'm using C#.  Apparently the menu layout is different.  Also, single-step is different (F10 instead of F8).

When "Redirect..." is not checked for me, Debug.Print writes to the Output window; when checked, Intermediate.  You might try unchecking it to see whether anything appears in Output.

Can you set a breakpoint on the Debug.Print statement?
Avatar of lcha

ASKER

I set the breakpoint but once the code starts running, it skips past the breakpoint and stops on the line after where I had set the breakpoint.

The red dot that marks the breakpoint also gets shifted down one.
ASKER CERTIFIED SOLUTION
Avatar of shadow77
shadow77

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lcha

ASKER

Ok, I found it after looking around a while.  

followed your instructions Project Menu --> xxx Properties

I went to the "Compile" tab and then Advanced Compile options and found the check box you mentioned.  

After checking it, the debug.print works!   thank you!




You're welcome.  Curiously, that flag does not seem to matter in C#.  It was off in my project.