Calling a C Function from CSharp

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.
 
N

Niki Estner

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.
 
G

Guest

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 :)
 
W

Willy Denoyette [MVP]

Just post the code that isn't working, I'm sure we can help you out.

Willy.
 
Y

Yan-Hong Huang[MSFT]

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.
 

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