Get structure inside structure using reflection

I'm having problems accessing the structure in the structure

namespace Some.NameSpace.ToAccess
{
    public struct HowTo
    {
        public const string Some_Static_Strings = "redudantString";
        public const string SomeOtherStatic_Strings = "someOtherRedundantString";
        public const string Option3 = SomeOption";

        public struct AccessMe
        {
            public static readonly string OPTION1 = 1.ToString;
            public static readonly string OPTION2 = 2.ToString;
            public static readonly string OPTION3 = 4.ToString;
            public static readonly string OPTION0 = 0.ToString;

            static AccessMe()
            {
            }
        }
    }
}

I looked at other similar issues, however my differences are that I also load the assembly at runtime, and not just use reflection to get the contents of a specific structure at runtime. Therefore, to intercept, I do not have a link to the library, which I repeat until runtime.

this is very similar to my problem Get the structure inside the structure using reflection , however I cannot do

FieldInfo FI = typeof(HowTo).GetType().GetField("Collection", BindingFlags.Public | BindingFlags.Instance);

because I need to get the type first, but that also doesn't work

var result = _someClass.PreLoadedAssembly.GetType("Some.NameSpace.ToAccess.HowTo").GetField("AccessMe", BindingFlags.Public | BindingFlags.Instance);

(PreLoadedAssembly is the assembly that I loaded at runtime and stored in _someClass)

, .

+3
1

GetNestedType:

_someClass.PreLoadedAssembly
          .GetType("Some.NameSpace.ToAccess.HowTo")
          .GetNestedType("AccessMe");
+2

All Articles