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 573001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:40:42+00:00 2026-05-13T13:40:42+00:00

The following code (packaged in a ‘Console Application’ Visual Studio project): using System; using

  • 0

The following code (packaged in a ‘Console Application’ Visual Studio project):

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace TestReflection
{
    class Program
    {
        static void Main(string[] args)
        {
            bool found = false;
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (assembly.GetType("System.Diagnostics.Process") != null)
                {
                    found = true;
                    break;
                }
            }
            Console.WriteLine(found);
            Console.ReadKey();
        }
    }
}

prints ‘True’ when running it in debug mode (F5), but ‘False’ when launching it without the debugger (Ctrl-F5). Other classes show similar behavior (System.Text.RegularExpressions.Regex), others are found in both cases (System.IO.File).

I’m probably missing something obvious – why is this happenning?

(same thing happens in both Visual Studio 2005 and 2008).

UPDATE

List of assemblies found:

Debug mode:

mscorlib
TestReflection
System
Microsoft.VisualStudio.HostingProcess.Utilities
System.Windows.Forms

Run mode:

mscorlib
TestReflection

As the answers imply, in run mode the System assembly is missing (not loaded). My problem was that I was assuming GetAssemblies() was also returning not loaded assemblies.

While this explains the behavior for System.Diagnostics.Process, why is my code finding System.IO.File in both run and debug modes?

Thanks!

UPDATE 2

I’ve changed the code to loop through the loaded assemblies and the current assembly, collecting a list of assemblies referenced by these. If after iterating the loaded assemblies I can’t find the type I’m looking for, I start loading and inspecting the referenced assemblies.

It seems that even if I have a reference to System.dll in my project (I’m looking at the properties of the ‘System’ reference in Visual Studio), my executable file only references mscorlib.dll (according to Reflector).

How do I add a ‘real’ reference to System.dll? Placing a dummy line

new System.Diagnostics.ProcessStartInfo();

at the start of Main does the trick (things work as expected, Reflector shows references for both mscorlib.dll and System.dll when inspecting the executable), but it is a hack.

Thanks again!

  • 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-13T13:40:42+00:00Added an answer on May 13, 2026 at 1:40 pm

    AppDomain.GetAssemblies does not return all assemblies that you have referenced, rather it returns all assemblies that are currently loaded into the appdomain.

    Clearly, the Diagnostics.Process class is not directly used by your application and will thus not be loaded when running outside the debugger.

    So why do we find System.IO.File but not System.Diagnostics.Process?
    The reason is that the two classes, though they reside in the same top-level namespace System, actually lives in two different assemblies. This is easily seen if you look up the two classes in the Visual Studio Object Browser. The File class happens to live in the mscorlib dll while the Process class lives in the System dll.

    Since no .Net application can run without mscorlib that assembly will be loaded, while System.dll is not loaded since you are not referencing any types that lives in that dll.

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

Sidebar

Ask A Question

Stats

  • Questions 381k
  • Answers 381k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can always call the URI Class in your library...… May 14, 2026 at 10:06 pm
  • Editorial Team
    Editorial Team added an answer "Am I reaching conclusions based on too little information and… May 14, 2026 at 10:06 pm
  • Editorial Team
    Editorial Team added an answer Why not just use the date_select form helper? http://apidock.com/rails/ActionView/Helpers/DateHelper/date_select May 14, 2026 at 10:06 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.