我开始在安装了.Net Framework 4.5的Windows 7 64位计算机上运行我的程序,它运行正常。 然后我尝试在安装了Net Framework 4.5的另一台Windows 7 64和32位机器上运行,我不知道为什么程序停止工作。
Problem Event Name: CLR20r3
Problem Signature 01: ExDraw.exe
Problem Signature 02: 1.0.2.3
Problem Signature 03: 59be5ce4
Problem Signature 04: mscorlib
Problem Signature 05: 4.6.1590.0
Problem Signature 06: 5787ed44
Problem Signature 07: f9d
Problem Signature 08: 96
Problem Signature 09: System.FormatException
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
这是我的代码
private void DownloadAddonsListCompleted(object sender, DownloadStringCompletedEventArgs e)
{
var result = StringHelper.DecryptMyString(e.Result);
foreach (var line in result.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
var statusAddons = File.Exists("Addons\\" + line.Split('~')[0] + ".addon")
? "Installed"
: "-";
var localAddonsVersion = "-";
if (statusAddons != "-")
{
localAddonsVersion = File.ReadAllText("Addons\\" + line.Split('~')[0] + ".version");
if (Convert.ToDouble(localAddonsVersion) < Convert.ToDouble(line.Split('~')[1]))
statusAddons = "Outdated";
}
var _WebClient = new WebClient();
var fileName = line.Split('~')[0].Replace(" ", string.Empty) + ".html";
_WebClient.DownloadFileTaskAsync(line.Split('~')[3],
RequiredPath.ADDONSDESCRIPTIONPATH + "\\" + fileName).Wait();
rgvList.Invoke(new Action(() =>
rgvList.Rows.Add
(
line.Split('~')[0],
statusAddons,
localAddonsVersion,
line.Split('~')[1],
line.Split('~')[2],
line.Split('~')[3],
line.Split('~')[4],
RequiredPath.ADDONSDESCRIPTIONPATH + "\\" + fileName
)));
}
}
答案 0 :(得分:1)
你的问题在
if (Convert.ToDouble(localAddonsVersion) < Convert.ToDouble(line.Split('~')[1]))
statusAddons = "Outdated";
您正在将文本转换为double,但您正在使用当前的机器文化进行操作。根据文化,小数分隔符可以变化;它可能是“。”,“”,甚至是其他东西。您的问题很可能与您的机器的不同文化有关。因此,当您进行这些转换时,您应始终设置转换文化。
您的情况有点不同,因为从您的评论到问题我得到的是您要比较的数据是格式为“1.0.0.0”的版本号。在这种情况下,Double
是转换格式的不良选择。 .NET框架附带System.Version
class进行这些比较:
if (new Version(localAddonsVersion) < new Version(line.Split('~')[1]))
statusAddons = "Outdated";