3

I want to add a C file into my .NET application.

How can I built this? How can i write unmanaged code in C#. Can someone explain with few lines code.

Thanks

1
  • if you want to use your c language function try to make a dll for this, and use dll with com components in your .net application. Commented Oct 7, 2010 at 16:12

1 Answer 1

10

You either have to build the C file into it's own DLL and then use P/Invoke in your C# code to call them or...

You could also try to port the C code to C# which would give you a completely managed codebase.

Sign up to request clarification or add additional context in comments.

2 Comments

I would recommend the second option.
@Alexander - If the C code-base is small, then I would agree. However, I've seen some pretty monolithic C files that would be difficult to port to C#.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.