an MFC-DLL using a namespace declared in a C# application

P

pieter.gevers

hi

I have a C# application (test.cs) that looks as like:

using System;

namespace CM
{ public class CallbackHandler()
{
}

public void PrintAttention(string out)
{ // print out out
}
}

Now I want to call the function PrintAttention(string out) from within
a function in an MFC-DLL.
How can I adress the function PrintAttention(string out) from the
MFC-DLL (unmanaged code C++).
I tried

#using "test.cs"
using namespace CM;

void function_in_MFC_DLL()
{ Callbackhandler test = new CallbackHandler();
test.PrintAttention();
}

When I write this I get a compiler error C2871 CM: a namespace with
this name does not exist

Can someone please give me advise or tell me what I'm doing wrong??

Thx in advance
 
J

jiangsheng[MVP]

change the compile option to add managed code support, and add the C#
assembly to project references
 

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