Upgrading a C DLL to a .NET Library

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a C DLL which i would like to import into my .NET service.
a) How do I convert the DLL so as to be refernced by a .NET service (I don't want to use PInovke)
b) I tried recreating the DLL in VS.NET as a VC# Class Library but I get this error - decleration of dllimport function not allowed.

Help!
 
GeRmlc,

You can not do this. If you want to access functionality from a DLL
that exports functions, then you will have to go through the P/Invoke layer.

The other option is to rewrite the code in a managed language.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

GeRmIc said:
Hi,

I have a C DLL which i would like to import into my .NET service.
a) How do I convert the DLL so as to be refernced by a .NET service (I don't want to use PInovke)
b) I tried recreating the DLL in VS.NET as a VC# Class Library but I get
this error - decleration of dllimport function not allowed.
 
Hi Nicholas

Thanks, I'm now basically porting(copying with some minor modifications) the whole DLL to Visual C++ MFC ISAPI Extension DLL, Hoping I could then integrate that DLL into my .NET application but i keep getting this erro

'definition of dllimport function not allowed', i've tried prefixing _declspec(dllimport) to the function declarations but still..

Any advice? Thank

----- Nicholas Paldino [.NET/C# MVP] wrote: ----

GeRmlc

You can not do this. If you want to access functionality from a DL
that exports functions, then you will have to go through the P/Invoke layer

The other option is to rewrite the code in a managed language

Hope this helps
 
=?Utf-8?B?R2VSbUlj?= said:
Thanks, I'm now basically porting(copying with some minor modifications)
the whole DLL to Visual C++ MFC ISAPI Extension DLL, Hoping I could then
integrate that DLL into my .NET application but i keep getting this
error

'definition of dllimport function not allowed', i've tried prefixing
_declspec(dllimport) to the function declarations but still...

You are treating C# like C++ - its totally different. Only the general syntax
is the same.

DLL's are unmanaged code - you cannot just simply import them into managed
code. You need to use P/Invoke which will create a bridge from your managed
code to the unmanaged DLL.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
 
Hi,

I have a C DLL which i would like to import into my .NET service.
a) How do I convert the DLL so as to be refernced by a .NET service (I
don't want to use PInovke)

Hello,

Why don't you want to use PInvoke ?
 
Back
Top