-5

I have a problem. I have written an external DLL in C but I want to use it in WinForms in C# in Visual Studio 2017. Always I added DLL using "Add reference", but now shows error, something like 'valid assembly or COM'. I added it to my debbag directory and also to project like normall file (add -> existing item). On my computer it works but on others computers shows errors, that exactly this DLL is not detected by compiler or just don`t exists. How can I solve this? Thanks for help

Jester
  • 56,577
  • 4
  • 81
  • 125
P.Manek
  • 11
  • 2
    A plain C DLL cannot be added "as a reference". You need to use P/Invoke and deploy the DLL (and all of its dependencies) with your project. Why do you have so many language tags on this question? – xxbbcc Feb 01 '18 at 17:55
  • you're absolutely going to get downvoted because you didn't bother to search before doing this. Check out DllImport – oppassum Feb 01 '18 at 17:55
  • googling 'call c function from c#' first hit https://stackoverflow.com/questions/11425202/is-it-possible-to-call-a-c-function-from-c-net – pm100 Feb 01 '18 at 18:10

1 Answers1

1

DLL written in C cannot add as a reference to C# project. You can PInvoke to call your C DLL.

Here is a good article.

Sampath
  • 1,173
  • 18
  • 29