2

Possible Duplicate:
How do I call unmanaged C/C++ code from a C# ASP.NET webpage

I have a dll file that is written in "C" language, i want to use it in C#. How can i do that?

Community
  • 1
  • 1
nightWatcher
  • 1,051
  • 3
  • 15
  • 28
  • 5
    This has been asked countless times already. Use the search function; you'll even find specific examples. [Calling C dll code from C#?](http://stackoverflow.com/questions/2916153/calling-c-dll-code-from-c), [How do I call unmanaged C/C++ code from a C# ASP.NET webpage](http://stackoverflow.com/questions/720004/how-do-i-call-unmanaged-c-c-code-from-a-c-asp-net-webpage), [How to call a C library from .NET](http://stackoverflow.com/questions/927569/how-to-call-a-c-library-from-net), etc. – Cody Gray - on strike Feb 09 '11 at 05:54

2 Answers2

3

You can use PInvoke

Platform Invocation Services (PInvoke) allows managed code to call unmanaged functions that are implemented in a DLL.

Here is a great tutorial by the NAG (Numerical Algorithms Group) group

Pieter Germishuys
  • 4,828
  • 1
  • 26
  • 34
2

You can do a DllImport in your C# code and then use PInvoke.

For your custom dll you can try this example answer on SO.

This a good website for reference for using windows dlls

Community
  • 1
  • 1
Shekhar_Pro
  • 18,056
  • 9
  • 55
  • 79