> 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

Signature
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"
> Hello,
>
[quoted text clipped - 17 lines]
>
> Thx
Mr Topom - 26 Apr 2005 11:29 GMT
Hello,
Thx for the answer.
I just tested and it works... But If I modify the managed class like
that :
namespace managedDll
{
public __gc class Native {
protected:
// Put the line below in comment and everything works
fine
::Native __nogc *unmanagedNativePtr; // <--- Reference
to the unmaged class
public:
void foo();
};
}
I have a compile problem and Native in the C# code is highlighted as
struct.
I am with VC 2003 and I can't change the compiler...
Any Idea ?
Denny Huber - 02 Jun 2005 22:03 GMT
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
>> 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 ?
[quoted text clipped - 78 lines]
>>
>> Thx