Debugging C# Code

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
wraith808
Posts: 8
Joined: Fri Apr 24, 2009 5:47 pm

Debugging C# Code

Post by wraith808 »

I followed the instructions in this thread, but had no success.

The steps in that link had it attempting to compile the current code file, so with looking at the macro tags, I was able to correct it.

My current settings:
  • Menu Text: MS Debugger '$PB.exe'
    Program Name: "$MsDbgClrPath$MsDbgClr"
    Arguments: /mditabs $PDD\bin\debug\$PB.exe
    Work Directory: $PDD\bin\debug\
But the macro tags for the vs debugger doesn't expand to the correct location, i.e.

Code: Select all

function key_macro()
    local message_text = ""

    -- Microsoft CLR Debugger Path
    message_text = message_text .. "\nMicrosoft CLR Debugger Path"      .. " = " .. macro_tag("$MsDbgClrPath")
    message_text = message_text .. "\nMicrosoft CLR Debugger Path"      .. " = " .. macro_tag("$MSCDP")

    -- Microsoft CLR Debugger
    message_text = message_text .. "\nMicrosoft CLR Debugger"      .. " = " .. macro_tag("$MsDbgClr")
    message_text = message_text .. "\nMicrosoft CLR Debugger"      .. " = " .. macro_tag("$MSCD")

    message_box(1, message_text, "Microsoft Visual Studio Macro Tags")
end

key_macro() -- run the macro

Expands to empty string for all four variations on the macro tags.

I've tried to change the way that I run Zeus also in order to run the vars batch file first, even though all of the other Macro Tags are working correctly just in case there was something there, but it still doesn't work.

What could I be doing incorrectly?
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

What could I be doing incorrectly?
I tried those macros at this end and I can confirm those macros expand to blank :(

The article you read was written some time ago and I think what is going wrong is things have changed since then :?

The $MsDbgClrPath, $MsDbgClr macro tags go into the registry to try to locate the debugger and in particular they go looking for local server details of the Microsoft.DbgClr.DTE class. I suspect that Microsoft.DbgClr.DTE class no longer exists :(

That article was written for C# 2.0 and I don't think Microsoft support the DbgCLR for later versions of C#:

http://msdn.microsoft.com/en-us/library ... 80%29.aspx

Cheers Jussi

PS: You raised the issue of Zeus not having a version control check out on edit option.

That feature has been added to the latest Zeus beta and I look to make that beta available shortly.
wraith808
Posts: 8
Joined: Fri Apr 24, 2009 5:47 pm

Post by wraith808 »

Well, I played around with it as much as I had time for. This isn't really a big deal for me since I will always have my primary solution open in visual studio, but it points to not currently being able to use Zeus IDE as my one stop shop if I decided to do so, which makes me sad.

What it appears that MS includes now to debug managed code from the command line is MDBG (http://msdn.microsoft.com/en-us/library ... .100).aspx). This is a more full featured debugger, however, and I couldn't get it integrated.

I use a batch file to do 'gets' from TFS, and I hacked that apart to do much of what the vsvars.bat file does in my own batch files, instead of having to append to the run of that to have the variables set. So I used this, and then sent the executable for the entry point for my solution to the batch file as a parameter to pass on to MDBG.

This works flawlessly. But since it is an integrated debugger, the return isn't what I expect- when it hits an error or breakpoint, it returns some sort of code, then quits... this all shows up in the tools window. But it doesn't as it stands allow me to debug.

In case you pursue this in future versions, I'm including below what I have done.

Tools Options
Program Type: Executable
Menu Text: MS Debugger '$PB.exe'
Program Name: C:\WINDOWS\System32\cmd.exe
Arguments: /k "C:\Development\Run\RunDebugger.bat "$PDD\bin\debug\$PB.exe""
Work Directory: $fdd

RunDebugger.bat

Code: Select all

REM *********************************
REM This batch file will run the msdbg commandline debugger for the supplied executable 
REM *********************************
@call :GetVSCommonToolsDir
@if "%VS100COMNTOOLS%"=="" goto error_no_VS100COMNTOOLSDIR

@call "%VS100COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit
@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR


call "%VSINSTALLDIR%\VC\bin\vcvars32.bat"

@if "%1"=="" goto error_no_parameter

@if EXIST "%1" (
	mdbg "%1"
) else (
	goto error_no_executable
)

@goto end

@REM -----------------------------------------------------------------------
:GetVSCommonToolsDir
@set VS100COMNTOOLS=
@call :GetVSCommonToolsDirHelper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper64  HKLM > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper64  HKCU > nul 2>&1
@exit /B 0

:GetVSCommonToolsDirHelper32
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO (
	@if "%%i"=="10.0" (
		@SET "VS100COMNTOOLS=%%k"
	)
)
@if "%VS100COMNTOOLS%"=="" exit /B 1
@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7\Tools\"
@exit /B 0

:GetVSCommonToolsDirHelper64
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO (
	@if "%%i"=="10.0" (
		@SET "VS100COMNTOOLS=%%k"
	)
)
@if "%VS100COMNTOOLS%"=="" exit /B 1
@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7\Tools\"
@exit /B 0

@REM -----------------------------------------------------------------------
:error_no_VS100COMNTOOLSDIR
@echo ERROR: Cannot determine the location of the VS Common Tools folder.
@goto end

:error_no_VSINSTALLDIR
@echo ERROR: Cannot determine the location of the VS installation.
@goto end

:error_no_parameter
@echo ERROR: executable to debug not supplied
@goto end

:error_no_executable
@echo ERROR: supplied executable does not exist - "%1"
@goto end

:end
Thanks for your help, though! And let me know if you have any further questions!
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

What it appears that MS includes now to debug managed code from the command line is MDBG (http://msdn.microsoft.com/en-us/library ... .100).aspx). This is a more full featured debugger, however, and I couldn't get it integrated.
Thanks for the link. I'll take another look at MDBG.

There is in fact a Zeus debugger plug-for MDBG but it was remove from the installer because the MDBG.exe seemed to no longer work with all version of .Net (I think MS made some changes to the .Net debug layer).

The version from the link says it is for .Net 4.5 so hopefully that debug interface is once again stable :)

Cheers Jussi
wraith808
Posts: 8
Joined: Fri Apr 24, 2009 5:47 pm

Post by wraith808 »

I'd be happy to try it if you direct me to a link to download it :D
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

I'll dust off that debugger code and prepare a new Zeus beta for you to test drive.

I'll should have something ready by the middle of next week so check back then for a download link ;)

Cheers Jussi
Post Reply