0

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

2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by sknake
0

How is that variable declared in the assembly? A static or const value? Is it a member of the class? You need to reflect in to the assembly.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.