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

Sam112 reputationPosted Jul 31, 2007, 2:18 PM EDT
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
Kyle5 reputationPosted Jul 31, 2007, 2:48 PM EDT
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;
}
Kyle5 reputationPosted Jul 31, 2007, 3:03 PM EDT
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.
Jan MontanoRank #1,295 · 1.3K reputationPosted Jul 31, 2007, 7:25 PM EDT
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
Sam112 reputationPosted Aug 1, 2007, 2:48 AM EDT
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