I'm developing a software with C# + Mono in Ubuntu which makes use of network classes like WebRequest
or Dns
. During development phase, I used my code to connect to a local webserver 192.168.1.101
and after a while I had to move it to 102.168.1.20
, and I used a local DNS server giving the mentioned IPs readable names (to simulate the real world scenario). But now, no matter what I do, I can not connect to the new server in my C# code! Here are things as they are:
$ ping myurl.local
=> 192.168.1.20$ nslookup myurl.local
=> 192.168.1.20Log from my code:
Dns.GetHostAddresses("myurl.local")[0].ToString()
=> 192.168.1.101
It seems to me that Mono has cached the DNS' resolved results from before and it won't let go of them. So I searched the Internet for it and I found this question. It has the same problem as mine but in Windows and .Net and also a solution. Unfortunately, its solution does not apply to mine, since ServicePointManager.DnsRefreshTimeout
is not implemented in Mono! The worst part is that the cache is persistent even if I restart the software and/or hardware thus I'm unable to proceed with my development!
So I wonder if there is a way I can reset Mono's cache, other than using DnsRefreshTimeout
? Even a manual solution will do for now (something I can do in shell!? Like removing a file perhaps!?).
I'm using Ubuntu 12.04 and Mono 3.2.3.