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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:02:40+00:00 2026-06-14T17:02:40+00:00

I understand from the api documentation that ReflectionOnlyGetType returns a type, much like GetType.

  • 0

I understand from the api documentation that ReflectionOnlyGetType returns a type, much like GetType. The difference is that with ReflectionOnlyGetType, the type is loaded for reflection only, not for execution.

So why does this work:

    Type t = Type.ReflectionOnlyGetType("System.Collections.Generic.List`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", false, false);
    ConstructorInfo[] cis = t.GetConstructors();
    foreach (ConstructorInfo ci in cis)
    {
        if (ci.GetParameters().Length == 0)
        {
            // ! no arg constructor found! let's call it!
            Object o = ci.Invoke(new Object[]{});
            Console.WriteLine("But wait, it was supposed to be reflection only??");
            Console.WriteLine(o.GetType().Name);
            List<String> lli = (List<String>)o;
            lli.Add("but how can this be?");
            Console.WriteLine(lli.Count);
            Console.WriteLine("I am doing a lot more than reflection here!");
        }
    }

My question is: I seem to be able to do more than reflect on the members of this type. Have I misunderstood “execution” when they say the type is loaded “for reflection only, not for execution”? Or is ReflectionOnlyGetType returning a different (non-reflection-only) type if the type was already “loaded” and here was loaded by virtue of being in mscorlib? Or is it something different entirely?

  • 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-06-14T17:02:42+00:00Added an answer on June 14, 2026 at 5:02 pm

    You are loading a type from mscorlib which has already been loaded for execution by the runtime. You can check the ReflectionOnly property on an Assembly to see if it is loaded into a ReflectionOnly context. In your sample,

    Type t = Type.ReflectionOnlyGetType("System.Collections.Generic.List`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", false, false);
    Console.WriteLine(t.Assembly.ReflectionOnly); // prints False.
    

    It seems reflecting over mscorlib is somewhat restricted. From MSDN:

    You cannot use the reflection-only context to load a version of
    mscorlib.dll from a version of the .NET Framework other than the
    version in the execution context.

    I’m guessing that extends to loading the one in the current execution context into the reflection-only context.

    It seems to work with other BCL assemblies:

    Console.WriteLine(Assembly.ReflectionOnlyLoad("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089").ReflectionOnly); // prints True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that Javadoc is a documentation generator from Sun Microsystems for generating API
I try to understand this example from jquery api in this snippet var tags
As far as I understand from the documentation the QUdpSocket are async but, still,
I found that Maven implies specific directory layout. But I don't understand from here:
I’m trying to understand code from http://www.yesodweb.com/book/conduits . After some fixes (like replacing Resource
I am trying to understand the documentation Using the Images Python API and I
I understand that the Windows API uses classes, relying to the WNDCLASS / WNDCLASSEX
I am implementing a PHP application that requires some data from Google Books API,
As you can understand from title, i modified Settings.cs file.Added some properties, some code
what is DesignMode property? When it is useful? I don't understand it from msdn

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.