Reading dll-Functions and execute them

H

Halimaji Nijazi

Hi everybody

I am trying to load an assembly (dll) an this works fine for me with:

Dim SampleAssembly As [Assembly]

SampleAssembly = [Assembly].LoadFrom("c:\clsHali.dll")


But now I like to read all public functions I have created and can't make
this work I have to public functions in it called hali1 and hali2... I have
tried it with getmethods, gettypes and whatever but never get the results I
needed...

How can I read all public functions of this assembly?

The second question is:
How can I execute the function or whatever if I found the function (hali1 or
hali2) I needed?

Thanks alot for every help!

Nijazi Halimaji
 
C

Carlos J. Quintero [VB MVP]

You first need to get the types ussing Assembly.GetExportedTypes (assuming
that your functions are in public types) and once you have a type you use:

objType.GetMethods or some variant.

Once you have a MethodInfo, to execute it you use:

objMethodInfo.Invoke(objectInstance, ....)

If you still have problems, post the minimal code to reproduce it in order
to us to take a look.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
 
H

Halimaji Nijazi

Thanks for the tips... I did it!

regards
Nijazi Halimaji
Carlos J. Quintero said:
You first need to get the types ussing Assembly.GetExportedTypes (assuming
that your functions are in public types) and once you have a type you use:

objType.GetMethods or some variant.

Once you have a MethodInfo, to execute it you use:

objMethodInfo.Invoke(objectInstance, ....)

If you still have problems, post the minimal code to reproduce it in order
to us to take a look.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com


Halimaji Nijazi said:
Hi everybody

I am trying to load an assembly (dll) an this works fine for me with:

Dim SampleAssembly As [Assembly]

SampleAssembly = [Assembly].LoadFrom("c:\clsHali.dll")


But now I like to read all public functions I have created and can't make
this work I have to public functions in it called hali1 and hali2... I
have tried it with getmethods, gettypes and whatever but never get the
results I needed...

How can I read all public functions of this assembly?

The second question is:
How can I execute the function or whatever if I found the function (hali1
or hali2) I needed?

Thanks alot for every help!

Nijazi Halimaji
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top