"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:61**********************************@microsof t.com...
You may be able to compile your C code in a Visual Studio.NET C++ project
with the /CLR switch and it will be compiled into a .NET managed assembly.
This can be a viable route, but it depends on the code. VC++ can compile
C++ to managed code, but not C, so the first step would be to get the C
code to compile as C++. To make it accessible to C#, you'd then probably
have to wrap the C-style API into a class-based API, since C# has no concept
of a free function.
In the end, you'll still end up with a separate DLL since you can't mix C++
and C# in a single DLL. (Actually, I think you can, but it's not for the
faint of heart). In that case, the best option may be to simply compile the
C code into a DLL and use P/Invoke to call it from C# and skip the
conversion to managed C++.
Which is best depends a great deal on the nature of the C code in question.
-cd