Namespace with managed C++ DLL and C# usage [Try #2]

M

Mr Topom

Hi,

It seems that I did not explain weel the problem so this is a new try :

Just a simple question :

I have a managed C++ DLL
I want to use it in a C# application.
So I added : #using MyNamespace.SubNameSpace; (which is part of the managed C++ DLL)

But when I want to use my class : MyNamespace.SubNameSpace.Klass in C#, I need
to put all the namespace and the class name alone is not recognized...

If I put :
MyNamespace.SubNameSpace.Klass k = new MyNamespace.SubNameSpace.Klass; //OK
Klass k = new Klass; // BAD

Any idea why ?

Thx
 
O

Olaf Baeyens

I have a managed C++ DLL
I want to use it in a C# application.
So I added : #using MyNamespace.SubNameSpace; (which is part of the managed C++ DLL)

But when I want to use my class : MyNamespace.SubNameSpace.Klass in C#, I need
to put all the namespace and the class name alone is not recognized...

If I put :
MyNamespace.SubNameSpace.Klass k = new MyNamespace.SubNameSpace.Klass; //OK
Klass k = new Klass; // BAD
Strange it should work.
But maybe there exist 2 variants of klass?

I also assume that you did put the dll as reference?
 
M

Mr Topom

In fact, my managed class 'klass' is a wrapper for an other class
'klass' which in an other DLL. Do you think that the unmanaged class
could be found in my managed DLL when I use the reference to the
managed one #using MyNamespace.MySubnamespace ?

Thx
Mr Topom
 
O

Olaf Baeyens

In fact, my managed class 'klass' is a wrapper for an other class
'klass' which in an other DLL. Do you think that the unmanaged class
could be found in my managed DLL when I use the reference to the
managed one #using MyNamespace.MySubnamespace ?
Probably yes, but then you have to avoid a reference to the other namespace
that also contains a class called Klass.
The "#using" is like telling that if something is not found then add this
prefix to that and try again.
But if you have 2 classes called Klass, it is not that easy for the compiler
to determin which one you really want.
 
M

Mr Topom

I know it would be difficult for the compiler to find the good symbol.
But the question is why does it find the unmanaged one in the C# code
?

I just tried to rename the managed class and it works... But I need
the same one.

Any idea or DLL param to prevent from having the symbol visible in the
..NET environment ?

Thx
 

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