import dll

  • Thread starter Thread starter Federico
  • Start date Start date
F

Federico

Hello,
first of all i wonna beg pardon for my bad english, but
its not my first language.

Here is my question:
How can i load in c# an external dll coded in c# or vb.net?

I know that to load dll coded in c++ etc.. u must use, for
example

[DllImport("advapi32.dll", SetLastError=true)]
public static extern bool LogonUser(...)

but since in .net languages i havent found how functions
in a dll can be exported,
if i use the same code at run-time the system says
it can not find the EntryPoint to my dll.

any idea?

Thanks a lot.

Federico
 
Hello,
first of all i wonna beg pardon for my bad english, but
its not my first language.

Here is my question:
How can i load in c# an external dll coded in c# or vb.net?

I know that to load dll coded in c++ etc.. u must use, for
example

[DllImport("advapi32.dll", SetLastError=true)]
public static extern bool LogonUser(...)

but since in .net languages i havent found how functions
in a dll can be exported,
if i use the same code at run-time the system says
it can not find the EntryPoint to my dll.

Look at the System.Reflection.Assembly class. you can use it to load an
assembly and then use reflection to get the information you wish.

If you try to do the dynamic linking, you could do like this:

1. create an interface IMyInterface and put it in some fixed library
2. prepare a set of libraries with classes that implement interface
IMyInterface.
3. in the main module that should use any library from 2., you just load the
library assembly and use reflection to get the types that implement
interface IMyInterface. then, you can use such types as regular types in
your application by casting each one to IMyInterface when needed.

regards, Wiktor Zychla
 
Back
Top