I am once again trying to call a MC++ method from a C# method. I am building
with the command line, not the IDE. This is my build file:
cl /clr mc.cpp
csc /r:mc.exe /t:module csh.cs
Here are the source files:
csh.cs
using System;
using MCfu;
namespace InHere
{
public class AppClass
{
static void CSFu1()
{
Console.WriteLine("In CSFu");
MCfu.MCClass.HereIsFu();
}
static void CSFu2()
{
Console.WriteLine("In CSFu");
}
}
}
Here is mc.cpp:
#using "mscorlib.dll"
#using <System.Windows.Forms.dll>
using namespace System;
namespace MCfu
{
class MCClass{
public: static void HereIsFu(void)
{
Console::WriteLine("HereIsFu");
}
};
}
int main(void)
{
Console::WriteLine("MCpp Main");
MCfu::MCClass::HereIsFu();
}
When I build, the C# build gives the following error:
csh.cs(2,7): error CS0246: The type or namespace 'MCfu' could not be found.
I would appreciate any suggestions about what is not correct. Thanks.
Willy Denoyette [MVP] - 10 Jun 2005 19:01 GMT
namespace MCfu
{
class MCClass{
...
must be a managed class!
Willy.
>I am once again trying to call a MC++ method from a C# method. I am
>building
[quoted text clipped - 56 lines]
>
> I would appreciate any suggestions about what is not correct. Thanks.
Richard MSL - 13 Jun 2005 17:35 GMT
Thanks, that solved the problem. Adding managed __gc to the class definition
made it work.
> namespace MCfu
> {
[quoted text clipped - 65 lines]
> >
> > I would appreciate any suggestions about what is not correct. Thanks.