有什么主意吗?该计算机是Windows 2012R2,也是域控制器.我尝试用相同的用户执行这个小应用程序,唯一的区别是RDP/Local 谢谢您的帮助解决方案 double.Parse 使用您的当前环境上的system.globalization.cultureinfo.currentculture%28v = vs.110%29.aspx"rel =" nofollow> CurrentCulture 设置类似远程环境的声音使用的文化没有.作为 NumberDecimalSeparator ,这就是为什么您获得 FormatException 的原因.作为替代方案,您可以使用 InvariantCulture 作为解析方法中的第二个参数,该参数具有.作为 NumberDecimalSeparator . double d = double.Parse(s,CultureInfo.InvariantCulture); 或者您可以将远程环境的区域性设置更改为在本地环境中使用的相同区域性.I have a realy weird error. I have a .Net application, that make an exception while parsing a string to a double.But this is happening only trough RDP!I made a simple exe:static void Main(string[] args){ try { string s = "1.5"; double d = double.Parse(s); Console.WriteLine("RES: " + d); Console.Read(); } catch (Exception e) { Console.WriteLine("Message: "+e.Message+", trace: "+e.StackTrace); Console.Read(); }}When I execute on local it works, ut in RDP i have an errorAny idea? the machine is a Windows 2012R2, that is also a domain controller.I try to execute this little app with the same user, only difference is RDP/LocalThank you for your help 解决方案 double.Parse uses your CurrentCulture settings on the current environment by default.Sounds like your remote environment uses a culture that doesn't have . as a NumberDecimalSeparator, that's why you get FormatException.As an anternative, you can use InvariantCulture as a second parameter in your parsing method which has . already as a NumberDecimalSeparator.double d = double.Parse(s, CultureInfo.InvariantCulture);Or you can change the culture settings of your remote environment the same culture using in your local environment. 这篇关于为什么double.Parse()仅通过rdp抛出FormatException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 08:24