show definition (browse) in *.pdb of *.dll file - c#

I have built a Library project (DLL) in .NET. And sometimes I use the DLL along with its PDB file as a reference in some other projects.
Now in the new project, I cant browse through the code of the DLL to debug. I can only see the definitions of class/methods/variables. That's by using "show definition" by browsing through the "class view"
However, only in case of an exception I the contents of the DLL opens and I could see the entire code of the DLL from the new project.
How could I see the contents (code) of the DLL before an exception occur?

If you just need to browse the code, load the dll up in Reflector -- you don't even need the PDB file: http://www.red-gate.com/products/reflector/

If an app loads the DLL while running under the Visual Studio debugger, it should load the symbols automatically. If all you have is a DLL, you may need to write a "driver" app that does nothing but load and exercise the DLL entry points.

If you want to debug your application programmaticaly, take a look at Mdbg (managed dbg).
You can also take a look at pdb2xml source, which give you good example of ISymbolReader interface, and how to use it to read pdb files.

Use JustDecompile, it's free.

Related

How I can Decompile .dll file code and comment

i have a .dll file that written in c#
so i need to decompile .dll file to code with comment ??
I have tried many programs like (JustDecompile , dotpeek , ILSpy) but all of them are decompiling file with out comment.
For the full information you need a corresponding xml file for xml documentation, and a .pdb symbol file containing the metadata.
Without it you can "decompile", but you might find yourself having a hard time.
Note: the full info pdb is usually only provisioned with a debug version of the assembly. If you have an external dll, its not likely it will match.

Pdb file of Library not loaded into Application's bin folder

I have a solution with an application and a library. When debugging - breakpoints don't work and I've found (with the help of this answer) that it's because the pdb file of the library isn't copied into the application's debug folder.
I can change the output folder manually in Properties - Build - Output. But that seems like the wrong way. Visual Studio is supposed to do that automatically.
So: How do I fix Visual Studio to copy the pdb file?
You may not have a reference to the project, but to the DLL only.
Try to delete the reference to the library and add it again. Make sure you don't select the DLL as reference but select the project from from the reference manager:

How do I attach source code in VisualStudio 2013?

What is the best/correct way of attaching an external project source code so I can debug it?
I´ve already downloaded the source code of it from CodePlex, so I have all the .cs classes.
I´ve managed to import from a pdb file, but unfortunately, there´s no such file in this project codeplex (SimpleInjector).
After importing the SimpleInjector solution on VS, I could build it and generate the .pdb files, but I wonder whether it is the right way.
If your goal is to step-through debug the binary, then you will need the PDB files. In general, the compiled assembly just doesn't contain the information needed to associate source-code lines with individual IL commands.
The PDB file is a "program database file" which contains lots of useful debugging information; one of those things is the mappings between each compiled IL instruction and the source-code line that generate it. It also keeps a symbol table that lists the names of things that otherwise get compiled out (like local variable names, etc.) The PDB embeds the full path name of each source file, so if your source code is in the same place when you debug as it was when you compiled, the debugger will automatically find it.
If the .pdb file is present but the source code has moved, VS will give you the option to browse to the .cs file. But, if the .pdb file isn't present at all, your options will be rather limited.
The only risk you have is that you are debugging a program that doesn't match your PDB files. Therefore, if you are doing to try to debug the project, you should rebuild, from scratch, in Visual Studio and run that version of the binary.
(Debugging without symbols and source loaded into Studio is, of course, possible, but it's a much harder skill to master.)

VS 2010 Debugging

Is the .pdb file enough to debug and step into the code of a dll? Or do you actually have to reference the corresponding project source code?
I tried referencing a dll with the .pdb file in the same directory, and was unable to step into the code of the dll. So I was wondering what the rules around dlls and .pdb files where.
Thanks in advance.
The .pdb file will allow you to debug, but it will not provide any sources. Check out this blog post for an excellent description of PDB files and their purpose.
http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/05/11/pdb-files-what-every-developer-must-know.aspx
The PDB file is how visual studio knows how the executing code in the assembly corresponds to the lines in the source code. The answer to your question is yes, Visual studio needs the source code that the corresponding pdb was built from.
The pdb does not contain the source code packaged inside of it (well it can, but it is a bit of a hack and not many people do it), however the symbol server should automatically download it if it has the source available. However the pdb must match the exact version as the dll you are working with for it to download the source.
I have a small suspicion that you are trying to do the .NET framework source stepping and it is not stepping in to it. Microsoft has not updated the symbol servers with the current versions of the pdb files so source stepping is broken if you are running a up to date version of .net (at least until they release the new versions of the source files).

Convert .cs to .dll

How can I compile a .cs file into a DLL?
My project name is WA. In my bin folder after the compilation, I found:
WA.exe
WA.vshost.exe
WA.pdb
You have to compile it:
csc /t:library source.cs -> source.dll
Are you using Visual Studio?
If you create a Class Library project in VS, add your .cs file and then compile the project, the output will be a .dll file.
You use a compiler. Csc.exe comes with the .NET Framework.
Check this link: http://msdn.microsoft.com/en-us/library/78f4aasd.aspx
You can also use an IDE like Visual Studio if you want the development process to be easier.
Its automatically created for you when you run a build in visual studio. Check the bin folder in your project folder.
For your information there are two kinds of DLL file which named "Managed" and "Un-Managed". Managed type is which you can use and add to your references in Visual Studio IDE.
However, if you want to convert each classes separately to Dll, you can use new windows application-> class library. After debugging and running that you can find DLL file in your source destination. Try it.
P.S: Usually you forced to use more than one class in one DLL file.

Categories

Resources