samedi 26 décembre 2015

Cannot invoke an internal method within a dll

I have this class in a ddl file:

namespace A
{
    internal class PW
    {
        static PW()
        {
            //code
        }

        internal static string G(int num)
        {
            //more code
        }
    }
}

However, when I call this:

typeof(PW).GetMethod("G", BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(String) }, null);

I get null.

The dll file is referenced in the project and PW class is found.

I know I cannot invoke it with

A.PW.G(0);

But I will get cannot access internal class/method error which at least proves that the program is aware of its existence.

How do I call the G method?





Aucun commentaire:

Enregistrer un commentaire