Solved

DLL Classes and running functions

Posted on 2006-11-01
3
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 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