By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 1,990 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

Calling DLL atruntime

P: n/a
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,
Mar 31 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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]

Mar 31 '06 #2

P: n/a
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]

Mar 31 '06 #3

P: n/a
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
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@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]

Mar 31 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.