import dll

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Federico

    import dll

    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("adva pi32.dll", SetLastError=tr ue)]
    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
  • Wiktor Zychla

    #2
    Re: import dll

    > Hello,[color=blue]
    > 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("adva pi32.dll", SetLastError=tr ue)]
    > 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.[/color]

    Look at the System.Reflecti on.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


    Comment

    • Federico

      #3
      Re: import dll

      I will try ... many many thanks

      Comment

      Working...