Welcome to MSDN Blogs Sign
in | Join
| Help

Mike Stall's .NET Debugging
Blog

Notes on Managed Debugging, ICorDebug, and random .NET stuff

This Blog

About

Email

May

June 2006

Jul

S

M

T

W

T

F

S

28

29

30

31

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

1

2

3

4

5

6

7

8

Syndication

RSS 2.0

Atom 1.0

Search

Go

Archives

June 2006
(8)

May 2006
(3)

April 2006
(4)

March 2006
(31)

February 2006
(16)

January 2006
(18)

December 2005
(11)

November 2005
(23)

October 2005
(12)

September
2005 (22)

August 2005
(28)

July 2005
(10)

June 2005
(7)

May 2005
(4)

April 2005
(5)

March 2005
(9)

February 2005
(16)

January 2005
(6)

December 2004
(3)

November 2004
(4)

October 2004
(14)

September
2004 (2)

Navigation

Home

Photos

Post Categories

Compilers
& Languages (7)

Design
(22)

Edit-And-Continue
(EnC) (8)

FuncEval
(8)

ICorDebug
(54)

Interop
(mixed-mode) (15)

MDbg
(31)

Random
(68)

Sample
Code (21)

This
should be in MSDN (15)

Troubleshooting
(16)

Whidbey
(V2.0) (11)

Other Blogs

Andy Pennell's Blog

GreggM's Blog

Steve's Blog

Tim's .NET blog for web
developers

CLR blogs

David Notario (JIT Compiler)

Rick Byers (CLR)

Jonathan Keljo's blog

List of
all CLR blogs

David Broman (Profiling)

Thomas Lai's blog

Other links

All
about MDbg

What's new
in v2.0?

Who am
I?

How to build Mdbg apps

I often publish little samples in this blog based off MDbg
(which generally show off the debugging services in some way; such as app to
convert Pdb-->XML,
or this harness to print
all exceptions in an app). I generally call these apps "harnesses" because
they run on another app (the debuggee). I've gotten some questions about how to
build them, so here are some more details.

The big picture is that these samples just need a reference to the Mdbg dlls
and then all else is good. We ship Mdbg as a source sample and also in the .NET
2.0 SDK. See here
for a comparison. The key details are that:
- the sample has full source for
Mdbg. The sdk version does not.
- the sample has 4 dlls to link against:
Corapi, CorApi2, MdbgEng, MdbgExt.  The sdk just has 1 dll,
MdbgCore.
The 2 versions are very close and most test apps could be compiled
against either one.

Note MDbg
requires .NET 2.0. So V1.1 users are some what out of luck.

Here are more details:

The easy way: Do it all in VS 2005
If you have VS2005 installed
(even the C#
Express edition, which is free),
then you can:

Just install the Mdbg sample (details here).

Build it for a sanity check.

Create a new project for your test app. My samples are mostly C# console
applications

My samples are usually a single file; so you can just copy the sample off
the web page and then paste it into the newly created project file.

For the new project, add a reference to the Mdbg dlls from the other
projects (Corapi, CorApi2, MdbgEng, MdbgExt.)

Make sure it all builds.

Set the test app as your startup project and go. In some cases, you may
need to supply command line args to the test app.

This is nice because then everything is in VS. You get intellisense for all
of Mdbg, you can step between the new app and mdbg core, and you get
Edit-and-continue support.

The harder way: Do it all on the Command line (no VS)

If you don't have VS, you can still build an Mdbg app on the command
line.

Download both .NET 2.0 and the .Net 2.0 sdk. (X86 links are here
and here).

Copy the sample from the web page to some source file (eg, T.cs).

Copy mdbgcore.dll from the sdk into the same directory as T.cs

Compile it:
csc t.cs
/debug+ /r:mdbgcore.dll

Run t.exe.  It may need some command line args.

Other alternatives:
You could also download the mdbg sample and
build that without VS, and then build the test app against that; all on the
command line.
Or you could build just your harness in VS, and then add a
reference to mdbgcore.dll from the sdk.

Published Wednesday, June 28, 2006 10:54 AM by jmstall
Filed
Under: MDbg, Troubleshooting

Comment Notification

If you would like to receive an email when updates are made to this post,
please register here

You can also stay up to date using your favorite aggregator by subscribing to
the CommentRss
Feed

Comments

No Comments

What do you think?

Title
(required)*

Name required*

Your URL

Comments
(required)*

Remember Me?