Solved

DLL Classes and running functions

Posted on 2006-11-01
3
214 Views
Last Modified: 2010-04-16
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?

0
Comment
Question by:cossy74
3 Comments
 
LVL 12

Expert Comment

by:guidway
ID: 17855253
see:
http://my.execpc.com/~gopalan/dotnet/reflection.html 

under the section
"Obtaining Member Information from a Class"
0
 
LVL 11

Expert Comment

by:Mihai Stancescu
ID: 17856198
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
0
 
LVL 14

Accepted Solution

by:
existenz2 earned 500 total points
ID: 17857001
You can do that this way:

Type type = typeof(<Object>);
object oClass = Activator.CreateInstance(type);
                  
object[] arguments = new object[0];
object retVal = type.InvokeMember("<Method>",BindingFlags.Default | BindingFlags.InvokeMethod,null,oClass,arguments);


Replace <Object> and <Method> with the correct values.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now