Link to home
Start Free TrialLog in
Avatar of cossy74
cossy74

asked on

DLL Classes and running functions

Hi ,

Currently is use the Assembly.LoadFile function to load the DLL. This works :)
Then i use the SampleAssembly.GetTypes in a foreach loop to find the class i want. This works :)

Then i use the following to load the class:
    object oClass = Activator.CreateInstance(oClassType);

My question is, Without knowing the class structure of the DLL Class, how can i call a function inside that class?

Avatar of guidway
guidway
Flag of United States of America image

see:
http://my.execpc.com/~gopalan/dotnet/reflection.html 

under the section
"Obtaining Member Information from a Class"
If its a COM dll and you know its class reference you can call for example:

[DllImport("GDI32.DLL", EntryPoint = "CreateRectRgn")]
        private static extern int CreateRectRgn(int x1, int y1, int x2, int y2);

If its a .Net assembly just put in your using clause the name of the namespace registered in the assembly.

Regards,
Mishu
ASKER CERTIFIED SOLUTION
Avatar of existenz2
existenz2
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial