Home All Groups Group Topic Archive Search About

Calling DLL atruntime

Author
31 Mar 2006 4:01 AM
Michael Hesse
Hi,

I need to call a DLL. During development, I have had no problems using
"Declare" statements, but in production, I don't want to hard-code the path.

I would like to read the path fron an ini file and then load the DLL.  Is
there a VB.NET equivalent of LoadLibrary?

Thanks,

Author
31 Mar 2006 4:57 AM
Tom Shelton
Michael Hesse wrote:
> Hi,
>
> I need to call a DLL. During development, I have had no problems using
> "Declare" statements, but in production, I don't want to hard-code the path.
>
> I would like to read the path fron an ini file and then load the DLL.  Is
> there a VB.NET equivalent of LoadLibrary?
>
> Thanks,

You don't need a path in the declare statement...  You just need the
dll in the search path - and that will include the application
directory or the system directory.

--
Tom Shelton [MVP]
Author
31 Mar 2006 6:42 AM
R. MacDonald
Hello, Michael,

Tom's method is definitely the simplest, if you can be confident that
your DLL is always on the path (or if you can manipulate the path to
suit its location).

On rare occasions this might not be possible.  Then you might find the
method proposed (apparently independently) by Mike Woodring:

     http://staff.develop.com/woodring

and Richard Birkby

     http://www.codeproject.com/csharp/dyninvok.asp

to be helpful.

Cheers,
Randy


Tom Shelton wrote:
Show quoteHide quote
> Michael Hesse wrote:
>
>>Hi,
>>
>>I need to call a DLL. During development, I have had no problems using
>>"Declare" statements, but in production, I don't want to hard-code the path.
>>
>>I would like to read the path fron an ini file and then load the DLL.  Is
>>there a VB.NET equivalent of LoadLibrary?
>>
>>Thanks,
>
>
> You don't need a path in the declare statement...  You just need the
> dll in the search path - and that will include the application
> directory or the system directory.
>
> --
> Tom Shelton [MVP]
>
Author
31 Mar 2006 3:50 PM
Michael Hesse
Hi Randy,

It's a bit more complicated than I would hope, but certainly doable.  You
would think there would be a simpler way.

But I will give it a shot.

Thanks for the help.

Michael
Show quoteHide quote
"R. MacDonald" <sci***@NO-SP-AMcips.ca> wrote in message
news:442ccf4a$0$89514$dbd4d001@news.wanadoo.nl...
> Hello, Michael,
>
> Tom's method is definitely the simplest, if you can be confident that your
> DLL is always on the path (or if you can manipulate the path to suit its
> location).
>
> On rare occasions this might not be possible.  Then you might find the
> method proposed (apparently independently) by Mike Woodring:
>
>     http://staff.develop.com/woodring
>
> and Richard Birkby
>
>     http://www.codeproject.com/csharp/dyninvok.asp
>
> to be helpful.
>
> Cheers,
> Randy
>
>
> Tom Shelton wrote:
>> Michael Hesse wrote:
>>
>>>Hi,
>>>
>>>I need to call a DLL. During development, I have had no problems using
>>>"Declare" statements, but in production, I don't want to hard-code the
>>>path.
>>>
>>>I would like to read the path fron an ini file and then load the DLL.  Is
>>>there a VB.NET equivalent of LoadLibrary?
>>>
>>>Thanks,
>>
>>
>> You don't need a path in the declare statement...  You just need the
>> dll in the search path - and that will include the application
>> directory or the system directory.
>>
>> --
>> Tom Shelton [MVP]
>>