I want to call a function from a .net executable from my own code. I used reflector and saw this:
namespace TheExe.Core
{
internal static class AssemblyInfo
internal static class StringExtensionMethods
}
In namespace TheExe.Core is the function I am interested in:
internal static class StringExtensionMethods
{
// Methods
public static string Hash(this string original, string password);
// More methods...
}
Using this code I can see the Hash Method but how do I call it?
Assembly ass = Assembly.LoadFile("TheExe");
Type asmType = ass.GetType("TheExe.Core.StringExtensionMethods");
MethodInfo mi = asmType.GetMethod("Hash", BindingFlags.Public | BindingFlags.Static);
string[] parameters = { "blabla", "MyPassword" };
// This line gives System.Reflection.TargetParameterCountException
// and how to cast the result to string ?
mi.Invoke(null, new Object[] {parameters});
internalaccess modifier intent is this: not to let you do it. =)