How to access public varialbes in C# class
-
Dear friends I have small clarification I have c++ Dll which contains a class like these
public class Vector3d {
public:
float x, y, z;
Vector3d()
{
}
}when i try to access the class by adding reference in C# project I could only create object for Vector3d class i am unable to access variables (x,y,z) my Vector3d Metadata looks like these
[NativeCppClass]
[CLSCompliant(false)]
public struct Vector3d
{
}i could not find the variables in metadata also... what is the mistake i have done??? And what i have to do get the values to access? Thanks Joe.I
-
Dear friends I have small clarification I have c++ Dll which contains a class like these
public class Vector3d {
public:
float x, y, z;
Vector3d()
{
}
}when i try to access the class by adding reference in C# project I could only create object for Vector3d class i am unable to access variables (x,y,z) my Vector3d Metadata looks like these
[NativeCppClass]
[CLSCompliant(false)]
public struct Vector3d
{
}i could not find the variables in metadata also... what is the mistake i have done??? And what i have to do get the values to access? Thanks Joe.I
That's because you didn't make them
public
. Unless otherwise specified, all methods and data members arepriviate
..45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
That's because you didn't make them
public
. Unless otherwise specified, all methods and data members arepriviate
..45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001Dear john, thanks for reply Please check the second line in C++ class
-
Dear friends I have small clarification I have c++ Dll which contains a class like these
public class Vector3d {
public:
float x, y, z;
Vector3d()
{
}
}when i try to access the class by adding reference in C# project I could only create object for Vector3d class i am unable to access variables (x,y,z) my Vector3d Metadata looks like these
[NativeCppClass]
[CLSCompliant(false)]
public struct Vector3d
{
}i could not find the variables in metadata also... what is the mistake i have done??? And what i have to do get the values to access? Thanks Joe.I
I believe you will have to provide set_ and get_ methods in your C++ code to access the data as these are fields.
I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads
-
That's because you didn't make them
public
. Unless otherwise specified, all methods and data members arepriviate
..45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001C++ is different than C#. In C++, you only need to specify "public:" once above the members you want to be public, whereas in C# you need to specify "public" in front of each member you want to be public.
-
I believe you will have to provide set_ and get_ methods in your C++ code to access the data as these are fields.
I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads
Dear peter Thanks for the reply, i have not only public variables and also public methods. i could not access anything. i do not know where is my mistake. is there anything i need to do to access the public method of c++ class? i just added the dll in my reference, then i specified in the Using namespace. Thanks
-
Dear peter Thanks for the reply, i have not only public variables and also public methods. i could not access anything. i do not know where is my mistake. is there anything i need to do to access the public method of c++ class? i just added the dll in my reference, then i specified in the Using namespace. Thanks
Is this a managed C++ class? You can't add an unmanaged DLL to .NET like this - you need to either wrap it in a Managed C++ implementation, or you need to p/invoke into it.
I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads
-
That's because you didn't make them
public
. Unless otherwise specified, all methods and data members arepriviate
..45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001No, they're
internal
. /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com