因为某种原因,在输入时
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时,它是在我的计算机上寻找一个目录,而不是在网络上。
发布于 2014-05-28 21:51:29
类初始化器可能在初始化GetIP之前调用ownerURL。因此,ownerURL.Replace调用没有做您想做的事情。
为此,我建议您避免静态初始化;执行顺序很难预测。
https://stackoverflow.com/questions/23922399
复制相似问题