Weird "Inconsistent Accessibility" problem
-
I have two classes (of my own creation) that I instantiate in my app.
public partial class MyForm
{
MyObject1 m_myObject1;
MyObject2 m_myObject2;
}I have another class (ThreadData) that contains objects of those two classes as well (and I use the same names for the variables in this class as I do in the app).
public class ThreadData
{
MyObject1 m_myObject1;
MyObject2 m_myObject2;
}In a function, I create an instance of ThreadData, and use clones of the app's objects to set the objects in ThreadData. When I try to compile, I get this message:
error CS0052: Inconsistent accessibility: field type 'MyForm.MyObject1' is less accessible than field 'MyForm.ThreadData.m_myObject1'
Even if I don't use Clone(), it still gives me the same errors. Why?
"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." - Jason Jystad, 10/26/2001 -
I have two classes (of my own creation) that I instantiate in my app.
public partial class MyForm
{
MyObject1 m_myObject1;
MyObject2 m_myObject2;
}I have another class (ThreadData) that contains objects of those two classes as well (and I use the same names for the variables in this class as I do in the app).
public class ThreadData
{
MyObject1 m_myObject1;
MyObject2 m_myObject2;
}In a function, I create an instance of ThreadData, and use clones of the app's objects to set the objects in ThreadData. When I try to compile, I get this message:
error CS0052: Inconsistent accessibility: field type 'MyForm.MyObject1' is less accessible than field 'MyForm.ThreadData.m_myObject1'
Even if I don't use Clone(), it still gives me the same errors. Why?
"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." - Jason Jystad, 10/26/2001 -
I have two classes (of my own creation) that I instantiate in my app.
public partial class MyForm
{
MyObject1 m_myObject1;
MyObject2 m_myObject2;
}I have another class (ThreadData) that contains objects of those two classes as well (and I use the same names for the variables in this class as I do in the app).
public class ThreadData
{
MyObject1 m_myObject1;
MyObject2 m_myObject2;
}In a function, I create an instance of ThreadData, and use clones of the app's objects to set the objects in ThreadData. When I try to compile, I get this message:
error CS0052: Inconsistent accessibility: field type 'MyForm.MyObject1' is less accessible than field 'MyForm.ThreadData.m_myObject1'
Even if I don't use Clone(), it still gives me the same errors. Why?
"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." - Jason Jystad, 10/26/2001It basically means that
m_myObject1
is accessible, but its type,MyObject1
, is not. Something likeinternal class B
{}
public class A
{
public B b;
}In the example above,
A.b
is public, but the classB
is not.Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro
-
What's the accessibility on your MyObject1 type? m_myObject1 is public, so basically MyObject1 has to be the same.
Here's a better example of what I'm doing.
public class MyObject1 {}
public class MyObject2 {}
public class MyData
{
public MyObject1 myObj1;
public MyObject2 myObj2;public SetData(MyObject1 ojb1, MyObject2 obj2) { myObj1 = obj1; myObj2 = obj2; }
}
public partial class MyForm
{
private MyObject1 myObj1;
private MyObject2 myObj2;private void MyFunction() { MyData data = new MyData(); data.SetData(myObj1, myObj2); }
}
That should be perfectly okay.
"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." - Jason Jystad, 10/26/2001 -
Here's a better example of what I'm doing.
public class MyObject1 {}
public class MyObject2 {}
public class MyData
{
public MyObject1 myObj1;
public MyObject2 myObj2;public SetData(MyObject1 ojb1, MyObject2 obj2) { myObj1 = obj1; myObj2 = obj2; }
}
public partial class MyForm
{
private MyObject1 myObj1;
private MyObject2 myObj2;private void MyFunction() { MyData data = new MyData(); data.SetData(myObj1, myObj2); }
}
That should be perfectly okay.
"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." - Jason Jystad, 10/26/2001