473,507 Members | 13,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DLL Import Programatically?

I know how to use [DLLImport] when I know the path the DLL I'll be
importing. But I have the following scenario:

I have a series of DLL plugins that all have the exact same function
signatures just different implementations of them.

I'd like to programatically search a directory for them and import them
some how. Even though I know there signatures at compile time I won't
know the DLL file names till run time.

Any ideas how to do this?

Thanks very much.

Nov 17 '05 #1
3 2262
You can do this in .NET 2.0. What you would do is create a delegate
with the appropriate signature. Once you have that, you would call
LoadLibrary and GetProcAddress (through the P/Invoke layer) to get the
address of the function.

Finally, you would call the static GetDelegateForFunctionPointer method
on the Marshal class to get a delegate that represents the function in the
unmanaged dll you loaded.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<wa********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I know how to use [DLLImport] when I know the path the DLL I'll be
importing. But I have the following scenario:

I have a series of DLL plugins that all have the exact same function
signatures just different implementations of them.

I'd like to programatically search a directory for them and import them
some how. Even though I know there signatures at compile time I won't
know the DLL file names till run time.

Any ideas how to do this?

Thanks very much.

Nov 17 '05 #2
Nice, I'll look into that. Thanks very much for the info nick, I
appreciate it.

Nov 17 '05 #3
Tried your suggestion Nick and it works awesome. Thanks so much.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7020
by: google | last post by:
Is there anyway to programatically confirm that specific field names exist in the first row of a given Excel spreadsheet from code within Access? I have code set up to import data from our...
2
2325
by: john_aspinall | last post by:
For a kick off sorry if this is the wrong forum, Ill go on the Access one if Im not on the right board! Anyways, Ive got a problem and am not sure if its going to be solved programatically using...
0
1242
by: brian | last post by:
Hi there, I'm trying to figure out to to invoke the SqlServer 2005 Import/Export wizard programatically. I.e. Export DatabaseA.TableA to DatabaseB.TableA SqlBulkCopy seems nice but my...
0
1009
by: tapasi | last post by:
Hi, Can Anyone please tell me how to import 2000 database in vb.net 2003 by code. As well backup of sql server 2005 database in vb.net by code? Thanks in Advance.
0
7221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.