Calling a C Function from CSharp

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

Guest

Is there someone who can tell me how to call a piece of legacy code written in C from a CSharp program? I downloaded Eric Gunnerson's stuff and it doesn't work

I want to reuse a string manipulator which was written in C in ancient times to operate on some strings I am reading with a C# program I'm working on now.
 
Use PInvoke, MC++, or wrap the lagacy code within a COM component.
The MSDN contains tons of information on these topics.

Niki

JimT said:
Is there someone who can tell me how to call a piece of legacy code
written in C from a CSharp program? I downloaded Eric Gunnerson's stuff and
it doesn't work.
I want to reuse a string manipulator which was written in C in ancient
times to operate on some strings I am reading with a C# program I'm working
on now.
 
Well if it is a routine in a DLL you can use the [DLLImport("mydll.dll")] attribute on a method that defines that routine

Or you can port it :)
 
Just post the code that isn't working, I'm sure we can help you out.

Willy.
 
Hello Jim,

I was reviewing the thread. Have the problem beem resolved by the
community's suggestion? If there is any we can do, please feel free to post
here.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top