G
Guest
Dear VS Team,
using the Beta 2 of VS 2005 I've encontered the following problem.
Let's assume threre are three Dll's, one unmanaged and two managed. In the
unmanaged we put a simple unmanged struct "A" which is exported in the usual
way.
The first managed assembly defines a managed class "B" using the unmanaged
class "A" defined in the unmanaged Dll. This class "B" has got a public
member variable "a" of type "A*" and a function "get" returning "a".
The second managed assembly defines a managed class "C" having a member "b"
of type "B^". See the code below.
// Unamanaged DLL
struct A
{
int data;
};
// First Managed DLL (references unmanaged dll)
public ref class B
{
public:
A* a;
B()
{
a = new A();
}
A* get()
{
return a;
}
};
// Second Managed DLL (references unmanaged dll and first managed dll)
public ref class C
{
private:
B^ b;
public:
C()
{
b = gcnew B();
A* a0 = b->a;
A* a1 = b->get();
}
};
Compiling this code in VS 2003 (with the corresponding syntax changes of
course), everything goes well. In VS 2005 I get the following errror messages:
'B::a' : cannot access private member declared in class 'B'
and
'B::get': candidate function(s) not accessible
Does this mean, that a managed class can not have a function returning a
pointer to an unmanaged class??
Does the compiler declare the public member "a" in the managed class "B"
private on its own in order to make acessing to it from outside the assembly
impossible??
Best regards,
Martin Zenkel
using the Beta 2 of VS 2005 I've encontered the following problem.
Let's assume threre are three Dll's, one unmanaged and two managed. In the
unmanaged we put a simple unmanged struct "A" which is exported in the usual
way.
The first managed assembly defines a managed class "B" using the unmanaged
class "A" defined in the unmanaged Dll. This class "B" has got a public
member variable "a" of type "A*" and a function "get" returning "a".
The second managed assembly defines a managed class "C" having a member "b"
of type "B^". See the code below.
// Unamanaged DLL
struct A
{
int data;
};
// First Managed DLL (references unmanaged dll)
public ref class B
{
public:
A* a;
B()
{
a = new A();
}
A* get()
{
return a;
}
};
// Second Managed DLL (references unmanaged dll and first managed dll)
public ref class C
{
private:
B^ b;
public:
C()
{
b = gcnew B();
A* a0 = b->a;
A* a1 = b->get();
}
};
Compiling this code in VS 2003 (with the corresponding syntax changes of
course), everything goes well. In VS 2005 I get the following errror messages:
'B::a' : cannot access private member declared in class 'B'
and
'B::get': candidate function(s) not accessible
Does this mean, that a managed class can not have a function returning a
pointer to an unmanaged class??
Does the compiler declare the public member "a" in the managed class "B"
private on its own in order to make acessing to it from outside the assembly
impossible??
Best regards,
Martin Zenkel