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

该博客为转载内容,转载自https://www.cnblogs.com/cy163/archive/2005/12/21/302167.html ,涉及C/C++和C#相关信息技术内容。
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.

转载于:https://www.cnblogs.com/cy163/archive/2005/12/21/302167.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值