Willy has a good idea about using COM Interop to do it.
From a pure "C" perspective you can't do it. "C" has no notion of
namespaces, and .Net relies on them heavily. I base this on trying one of my
good old C++ "Hello World" pieces written in managed code and changing the
extension of the file from ".cpp" to ".c". For 3 lines of code I 20 errors
and numerous warnings.
Is there a problem with having a single file of C++ code mixed in with your
"C"? What about an external DLL written in C++ that acts as a shim to the
"C" code. The C++ code you have to write is really a lot like newer "C" code
(not like old K&R stuff). Here is a sample:
#using <mscorlib.dll >
#using <system.dll>
using namespace System;
void main()
{
String * str = new String(L"Now is the time for all good men to come to the
aid of their country.");
str = str->ToUpper();
Console::WriteL ine(str);
}
Note: You could just as easily import a DLL you wrote in C# and call it's
methods. I just used the Microsoft supplied System dll as an example.
(BTW: Don't take this the wrong way, but since I don't know how much of the
..Net stuff you are familiar with: The String is the System::String object
from the System.dll. Also, Console::WriteL ine() is
System::Console ::WriteLine() from System.dll. And, the String I new'ed will
automatically be garbage collected by the .Net framework since it is a __gc
class from the framework. So, I don't have to delete it.)
Otherwise, it looks like you are talking about Willy's idea of COM.
Hope this helps...
--
Frisky
Intellectuals solve problems; geniuses prevent them. ~ Albert Einstein
"GTi" <gt*@gti.com> wrote in message news:42******** @news.wineasy.s e...
Ok, that looks like C++, But what about pure C ?
"Frisky" <Fr***********@ NorthPole.net> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. It's not very hard at all.
You will have to make calls from unmanaged code into managed code. Its
not real hard, but I recommend at least VS2003. Basically all you will
need to do is a import your dll into the project, setup the name space,
and use a few special macros and keywords to setup your managed code.
Check out this article on Code Project on how to do it.
(http://www.codeproject.com/managedcp...to_managed.asp)
Hope this helps...
--
Frisky
Intellectuals solve problems; geniuses prevent them. ~ Albert Einstein
"dvtaylor" <dv******@gmail .com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . We write everything in plain old C. We have a potential customer that
wants to provide us a DLL written in C#. How can we call it's
functions?