Re: using protected methods in compact framework
- From: Sergey Bogdanov <sergey.bogdanov@xxxxxxxxx>
- Date: Wed, 04 May 2005 09:01:55 +0300
Please send a small reproducible sample.
Best regards, Sergey Bogdanov http://www.sergeybogdanov.com
Tommy wrote:
For some reason when i tried using derived classes on the .net compact framework it crashes.. is der a reason for this? no exception has come up or anything its simply crashes when it tries to connect.
Thanks and regards
Thomas Engerer
"Sergey Bogdanov" wrote:
Well, Client is a private property and can not be accessed from derived class. However, you can use reflection to achieve what you want:
System.Reflection.FieldInfo fi = typeof(TcpClient).GetField("Client", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); Socket s = (Socket)fi.GetValue(this); return ((IPEndPoint)s.LocalEndPoint).ToString();
Best regards, Sergey Bogdanov http://www.sergeybogdanov.com
Tommy wrote:
I have managed to use the protected methods in the .net framework.. however i need to use the protected method ".Client". so as to get the local endpoint of the current connected socket.
this is the code
public class MyderivedTcpClient : TcpClient
{
// Constructor for the derived class.
public MyderivedTcpClient() : base ()
{
}
public String getAddress()
{
// Calls the protected 'Client' property belonging to the TcpClient base class.
Socket s = this.Client;
return ((IPEndPoint)s.LocalEndPoint).ToString();
}
}
What solution could you suggest??
Thanks and regards
Thomas Engerer
.
- References:
- Re: using protected methods in compact framework
- From: Tommy
- Re: using protected methods in compact framework
- Prev by Date: Re: convert timespan to time/datetime...?
- Next by Date: Re: Asynchronous
- Previous by thread: Re: using protected methods in compact framework
- Next by thread: Re: using protected methods in compact framework
- Index(es):
Relevant Pages
|