zoukankan      html  css  js  c++  java
  • Dynamic load of a c++ dll in C#?http://www.codecomments.com/archive29020047216328.html

    http://www.codecomments.com/archive290-2004-7-216328.html
    Author
    Dynamic load of a c++ dll in C#?
    http://www.codecomments.com/archive290-2004-7-216328.html
    lallous

    2004-06-16, 8:57 am

    Hello

    I'm new to C# and wonder if it is possible as it is possible in C++ to
    dynamically load a DLL and use it in C#.

    The dll is written in C++ and has the following export:
    int test(void);

    and the code resides in test.dll

    I want a C# application that when I press Button1, it should
    dynamically load test.dll and its 'test' function and call it and get
    its return value.

    Is this possible in C#? If so, how?

    --
    Elias
    Bob

    2004-06-18, 3:57 am

    I guess your dll is unmanaged. Write a managed wrapper in C++ and use this in C#.

    ----
    Bob
    www.componentXtra.com
    Graph Controls/Components for .NET
    rawal

    2004-07-16, 4:19 pm

    Hi Bob,
    May be it is a stupid question, but I am new to .Net and I am wondering if you can please help me.
    How can you dynamically load a component in c#. Imean I understand that you can do the new and can have an instance of a component but for that it is also required to use "using component class".

    What I want to achieve is to read teh name of component from some out side file and then can instantiate it.

    Regards,
    Rawal.
    Stuart Carnie

    2004-07-20, 3:57 am

    Do you want to instanciate a managed class or a set of exported
    functions from a DLL?

    Cheers,

    Stu
    rawal <rawal.19imdq@mail.codecomments.com> wrote in message news:<851526108ea4250abc8be46cf9a31a9c@news.thenewsgroups.com>...
    > Hi Bob,
    > May be it is a stupid question, but I am new to .Net and I am wondering
    > if you can please help me.
    > How can you dynamically load a component in c#. Imean I understand
    > that you can do the new and can have an instance of a component but for
    > that it is also required to use "using component class".
    >
    > What I want to achieve is to read teh name of component from some out
    > side file and then can instantiate it.
    >
    > Regards,
    > Rawal.

    Dincer Ozturan

    2004-07-20, 8:58 am

    Hi,

    You can dynamically load a managed component (.dll) by using the
    components under System.Reflection namespace, like
    "System.Reflection.Assembly". You can load the dll by using
    System.Reflection.Assembly.Load(..)
    System.Reflection.Assembly.LoadFile(string FileName)
    System.Reflection.Assembly.LoadFrom(string FilePath)
    methods. If you do not have managed dll, you have to wrap it and load
    the wrapper. After loading you can use the loaded component by using
    the other classes under same namespace(Sys.Ref).

    Regards,
    Dincer

    rawal <rawal.19imdq@mail.codecomments.com> wrote in message news:<851526108ea4250abc8be46cf9a31a9c@news.thenewsgroups.com>...
    > Hi Bob,
    > May be it is a stupid question, but I am new to .Net and I am wondering
    > if you can please help me.
    > How can you dynamically load a component in c#. Imean I understand
    > that you can do the new and can have an instance of a component but for
    > that it is also required to use "using component class".
    >
    > What I want to achieve is to read teh name of component from some out
    > side file and then can instantiate it.
    >
    > Regards,
    > Rawal.

  • 相关阅读:
    OpenStack对象存储管理手册(5) OpenStack对象存储系统管理3
    hdu1568Fibonacci
    智能手机中显示信号强度格数
    上篇日本人经营之道 一破坏对手的情绪乱其方寸
    基于Wince的计算器程序
    shell 字符串操作
    轻松记住大端小端的含义
    如何把手机变成你的救生设备
    PM是一个事实
    mysql 5.6 online ddl 测试
  • 原文地址:https://www.cnblogs.com/cy163/p/302167.html
Copyright © 2011-2022 走看看