Home All Groups Group Topic Archive Search About

Reading dll-Functions and execute them

Author
16 Jan 2006 10:01 AM
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

Author
16 Jan 2006 3:41 PM
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


Show quoteHide quote
"Halimaji Nijazi" <t***@hotmail.com> escribió en el mensaje
news:OYYr7OoGGHA.2000@TK2MSFTNGP15.phx.gbl...
> 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
>
>
Author
16 Jan 2006 4:50 PM
Halimaji Nijazi
Thanks for the tips... I did it!

regards
Nijazi Halimaji
Show quoteHide quote
"Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> schrieb im
Newsbeitrag news:%23JRfRNrGGHA.3176@TK2MSFTNGP12.phx.gbl...
> 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" <t***@hotmail.com> escribió en el mensaje
> news:OYYr7OoGGHA.2000@TK2MSFTNGP15.phx.gbl...
>> 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
>>
>>
>
>