What I want to do is to load in a dll dynamically (which I think I have achieved with this code below, a message box is showing the name of the class within the dll file). I then want to return the value of a variable which is defined by the string 'variableName'.
Any ideas?
private void Form1_Load(object sender, EventArgs e)
{
classLocation = @"E:\Projects\Dll\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll";
variableName= "HelloWorld";
CallClass1(classLocation,className);
}
static void CallClass1(string filename, string className)
{
string fullFileName = new System.IO.FileInfo(filename).FullName;
Assembly assembly = Assembly.LoadFile(filename);
foreach (Type type in assembly.GetTypes())
{
//Get the property of variable 'variableName'
MessageBox.Show(type.ToString());
}
}
Thanks, Chris