Home c# Compile application, .pdb file

Compile application, .pdb file




Hello everyone. You may notice that after compiling the Visual Studio application, in addition to .exe files, .dll and others, it also adds .pdb files.

As far as I know, these files allow you to see a little more in the information about the exception. If I’m not mistaken, they allow you to see in StackTrace the file and line of code where the exception occurred.

The question is, is there actually any other practical use of these files (.pdb ) in the compiled application?

Answer 1, authority 100%

Availability symbol files (.pdb ) on the client machine can be useful in that in the event of an unhandled exception, if there is a .pdb file, you can get a more detailed stack trace .

For example, let’s create a simple console application that throws an exception and see how it looks with and without a symbol file.

using System;
namespace ConsoleApplication4
  class Program
    static void Main ()
      Do1 ();
    static void Do1 ()
      Do2 ();
    static void Do2 ()
      Do3 ();
    static void Do3 ()
      var i = 1;
      var s = "a";
      var b = true;
      throw new Exception ("Any exception");

Run without the .pdb file and get:

Run with .pdb file and get:

As you can see, in the second case, in stack trace you can see the file name and line number in which the exception occurred.

Answer 2, authority 29%

The pdb files contain debugging information.

The fact is that during compilation, there is no information about which line of the source code a particular construct corresponds to in the compiled code, it is simply not needed for execution. Likewise, information about what local variables are named is not included in the compiled code.

All such information needed for debugging is added to pdb by the compiler.

The rest of the information, such as where in the stack to find a parameter or local variable, or class / structure definitions, are not needed in pdb for .NET, this is already in the metadata.

Additional reading on the topic: PDB Files: What Every Developer Must Know .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions