adding c style dll to c# app

S

saleh

hi,

i have a dll with its .h file,in the .h i found the [ extern "C" ] .
when i tried to add the dll to a c# app ,it give me that error
[please make sure that it is a valid com or assembly component]

so does anyone could help me to add the .dll to my app.

note: i don't have the source code.

thanks.
 
S

saleh

hi Gary ,

thanks for your reply ,but it solve diifrent problem not mine

my problem is:the VS don't allow me to add reference to the dll from
the start and give me that error.

thanks,
saleh
 
W

Willy Denoyette [MVP]

saleh said:
hi,

i have a dll with its .h file,in the .h i found the [ extern "C" ] .
when i tried to add the dll to a c# app ,it give me that error
[please make sure that it is a valid com or assembly component]

so does anyone could help me to add the .dll to my app.

note: i don't have the source code.

thanks.


You can't add a "native code" dll to a C# project, C# cannot statically link to DLL's . If
you need to call "C" style functions exported from DLL's from C#, you'll have to import the
functions using the DllImport attribute. Search MSDN for details on PInvoke and DllImport.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top