Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6627247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:59:26+00:00 2026-05-25T21:59:26+00:00

I have a .NET solution which consists of several projects. It’s possible to say

  • 0

I have a .NET solution which consists of several projects. It’s possible to say that one of these projects is logically a primary one and all others are secondary. Our team has decided to build the project the next way. The main project will produce an assembly (I’ll refer it to as Primary). All other projects’ assemblies are Secondary and they will be embedded as a resource into the Primary one.

The SourceCodeForExceptionHelper class in the Primary project is responsible for getting the original source code using PDB files on every encountered exception. To do that I use the approach described here. It worked correctly in my separate proof of concept project. But when I tried to move that class into the real solution I’ve encountered a problem: the IMetaDataDispenser.OpenScope method requires not null reference to assembly file’s path. Surely, I haven’t such a reference for any of Secondary assembly (because their files are embedded in the Primary). For that reason I can’t create an object of the type ISymbolReader and read the source code. How can I solve that problem? By the way, the problem is even worse because we embed only Secondary assemblies without their PDB files (though we will do it if it is necessary).

Thanks in advance for any help and advice!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:59:26+00:00Added an answer on May 25, 2026 at 9:59 pm

    I don’t think you can do this using the .NET Framework builtin functions, as they rely on physical files. However, there is a solution using the Mono Cecil library, as it has an overloads that takes a Stream as input instead of a file path for its symbols reader.

    Here is an example of a Console app named “TestPdb” which dumps its IL code to the console, including PDB information:

    using System;
    using System.IO;
    using Mono.Cecil;
    using Mono.Cecil.Cil;
    using Mono.Cecil.Pdb;
    
    namespace TestPdb
    {
        class Program
        {
            static void Main(string[] args)
            {
                // we use a Stream for the assembly
                AssemblyDefinition asm;
                using (FileStream asmStream = new FileStream("testpdb.exe", FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    asm = AssemblyDefinition.ReadAssembly(asmStream);
                }
    
                // we use a Stream for the PDB
                using (FileStream symbolStream = new FileStream("testpdb.pdb", FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    asm.MainModule.ReadSymbols(new PdbReaderProvider().GetSymbolReader(asm.MainModule, symbolStream));
                }
    
                TypeDefinition type = asm.MainModule.GetType("TestPdb.Program");
    
                foreach (MethodDefinition method in type.Methods)
                {
                    Console.WriteLine("Method:" + method.Name);
                    foreach (Instruction ins in method.Body.Instructions)
                    {
                        Console.WriteLine(" " + ins);
                        if (ins.SequencePoint != null)
                        {
                            Console.WriteLine("  Url:" + ins.SequencePoint.Document.Url);
                            // see http://blogs.msdn.com/b/jmstall/archive/2005/06/19/feefee-sequencepoints.aspx
                            if (ins.SequencePoint.StartLine != 0xFEEFEE)
                            {
                                Console.WriteLine("  StartLine:" + ins.SequencePoint.StartLine + " StartColumn:" + ins.SequencePoint.StartColumn);
                                Console.WriteLine("  EndLine:" + ins.SequencePoint.EndLine + " EndColumn:" + ins.SequencePoint.EndColumn);
                            }
                            // etc...
                        }
                    }
                }   
            }
        }
    }
    

    NOTE: since you only need to read from PDBs, you can recompile the Cecil library defining the READ_ONLY conditional symbol to save some bytes. You can also embed Cecil source code directly in your assemblies, no need to use the .DLL versions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a .NET solution that consists of several assemblies, most of which
I have several projects and a website in a large asp.net solution. In some
I have a .NET solution which was badly organised, so I moved some projects
I have a large solution which contains a mixture of C# and VB.Net projects.
We have a distributed .net system which consists of several solutions, each with different
I have a .NET 4.0 C# solution with a tests project which runs unit
We have VS.Net solution with 20 projects in it. Occasionaly, in VS.NET, when we
I have a simple question. Let's say I have a .Net solution, with different
I have inherited a reasonable sized ASP.net solution that has no automated tests. The
I have a lot of projects in my .NET solution. I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.