Here is my problem guys.
I have two CS files:
CS1:
namespace BothSame:
.......
CS2:
namespace BothSame:
......
CS1 calls a method in CS2 passing it an object reference. This object has a private member which I would like to edit in this method (in CS2).
If both CS1 and CS2 are compiled in the same project i can do this easily, no problem.
However when I compile CS2 separately as a DLL and include it in CS1, the method is called fine, however when i go to edit the private member, it won't change. No exceptions are thrown either.
Any ideas?
Loading
SamPosted Aug 1, 2007, 6:48 AM
Hi Kyle,
Jan's advice seems good
I can't understand why the code even compiles if
your trying to acess a private member of another class.
(Maybe i'm not quite getting your situation)
Sam
Jan MontanoPosted Jul 31, 2007, 11:25 PM
If you could modify the 3rd party API, you should declare the member int size as public. And CS2.changeSize should also be declared as public if you want to access it from CS1.
Regards,
Jan
KylePosted Jul 31, 2007, 7:03 PM
In the same situation I'm also having trouble setting an event handler.
Object.messageEvent += new MessageEvent(myClass.myEventHandlingMethod);
myClass is in CS2 which is compiled in an external DLL
myEventHandlingMethod is declared as public static void
It compiles fine, however I get an Null Exeption at runtine.
KylePosted Jul 31, 2007, 6:48 PM
Well I am working with an API from a 3rd party product and the member is being declared as private in their dll.
So say the object is a Shape typeand it has a member called int size.
I want to be able to do the following:
CS1:
Shape x = new Shape();
changeSize (x);
CS2:
private void changeSize (Shape x)
{
x.size = 22;
}
SamPosted Jul 31, 2007, 6:18 PM
Also why are you trying to acess a private
member form another other object doesn't
that beat the point of it being private?
Sam