Kapil:
I tried this under VS8 Beta2 and I'm confused. Why is there a class in
def.cpp called Native and a class in m.cpp also called Native?
When I build this, I see "N::Native::foo". I would like to see "native foo
called".
I would like to instantiate an object of the class Native that lives in
def.cpp and run it inside N::Native::foo(). Can this be done?
Thanks,
Denny Huber
"Kapil Khosla [MSFT]" <kk*****@online.microsoft.com> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Is there a solution to remove the knowledge of the unmanged symbol to be
able to refer K in C# with only its name and not Mynamespace.K ?
I tried your example with beta2 toolset and I am able to call into the
managed assembly and dont get the compilation error. This is what I did.
cl /EHsc /LD def.cpp
cl /clr /LD m.cpp /link def.lib
csc /r:m.dll t.cs
////////////////def.cpp
#include <stdio.h>
class __declspec(dllexport) Native
{
public:
void foo()
{
printf("native foo called\n");
}
};
////////////////m.cpp
using namespace System;
class __declspec(dllimport) Native
{
public:
void foo();
};
namespace N
{
public ref class Native
{
public:
void foo()
{
Console::WriteLine("N::Native::foo");
}
};
}
///////////////////t.cs
using System;
using N;
class Test
{
static void Main()
{
Native obj = new Native(); // No compilation error
obj.foo(); // foo in namespace N called
}
}
Does this work for you? If not, can you tell me the compiler you are using
so that we can try to find what is going on?
Thanks,
Kapil
--
This posting is provided "AS IS" with no warranties, and confers no
rights."Use of included script samples are subject to the terms specified
at
http://www.microsoft.com/info/cpyright.htm"
"Mr Topom" <mr*****@yahoo.com> wrote in message
news:4a**************************@posting.google.c om... Hello,
I have a C++ (unmanaged) class named K in a DLL.
I create a managed C++ class named K in an other DLL that wrapped the
unmanaged one.
To refer the unmanaged one I use ::K and the managed one is in a
namespace MyNameSpace.
If want to use my managed DLL in a C# project,so I added : #using
Mynamespace;
If in the code I put :
K klass = new K;
There is compilation error. It seems that le K sybol is the unmanaged
one and identifyed as a 'struct'.
Is there a solution to remove the knowledge of the unmanged symbol to be
able to refer K in C# with only its name and not Mynamespace.K ?
Thx