如何解决“String未被识别为有效的DateTime”。在asp.net只在Windows 8? [英] How to solve "String was not recognized as a valid DateTime" in asp.net only in windows 8?

查看:56
本文介绍了如何解决“String未被识别为有效的DateTime”。在asp.net只在Windows 8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai

如果我运行网站我只会在今天获得字符串未被识别为有效日期时间,但在此工作正确之前,我不会更改任何代码,只是我改变操作系统只有Windows 7到Windows 8.



实际上我会读取日期和时间表格,如

Hai
if i run web site i will get "String was not recognized as a valid DateTime" just today only,but before this work correctly,i am not change code anything ,just i change OS only Windows 7 to Windows 8.

Actually i will read date and time form registry like

Dim lastRunDateForActiveLock As Date
lastRunDateForActiveLock = Convert.ToDateTime(FirstUseReg.GetValue("runDate"))





正确运行在Windows 7中的相同代码,但安装Win 8后它将在win 8中显示错误,如果我在其他操作系统中发布和部署它有效,我不知道为什么这条线在win 8中不起作用



actualli我将在runDate中获得12/23/2013 12:00:00 AM的价值,我会尝试声明sting var并获取runDate,然后将string var传递给Conve rt.ToDateTime(字符串var),但没有工作,



注意:相同的代码将在Windows 7中工作,如果我转换datatime我会得到12/23 / 2013,这也是我的需要。

i会尝试像lastRunDateForActiveLock = DateTime.ParseExact(FirstUseReg.GetValue(runDate),dd / MM / yyyy,CultureInfo.InvariantCulture)但是不工作



请回复asap



问候

Aravind



the same code run in windows 7 correctly,but after install Win 8 it will show error in win 8,if i publish and deploy in other os it works,i dont know why this line not work in win 8

actualli i will get value in runDate as "12/23/2013 12:00:00 AM",i will try to declare sting var and get "runDate" and then if pass string var to Convert.ToDateTime(string var),but no work,

Note: same code will work in windows 7,if i convert datatime i will get "12/23/2013" ,this is also my need.
i will try like " lastRunDateForActiveLock = DateTime.ParseExact(FirstUseReg.GetValue("runDate"), "dd/MM/yyyy", CultureInfo.InvariantCulture)" but not work

pls reply asap

Regards
Aravind

推荐答案

嗨Aravindba,



Hi Aravindba,

FirstUseReg = Registry.LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\LICENSE\runDate", True)

是指哪个操作系统?



因为我没有Windows 8操作系统,所以我猜



我认为注册表值仅用于处理windows7或更旧,以确认它尝试在您的注册表中搜索runDate值,例如



在Windows 8机器打开注册表编辑器中



refers to which OS?

Since I dont have windows 8 OS so I guess

I think registry value is handled only for windows7 or older, to confirm it try to search runDate value in your registry like

In Windows 8 Machine open registry editor by

1)Press Win(key)+ R then type 'regedit.exe'(without quotes) and ok<br />
2)Search for the value 'runDate' in that if you have then match the path with the one that you have in your solution.<br />
3)If path is not defined in your solution try to create a path for the value in registry and test the application.





如果您有价值,那么它应该是具有Datetime文化的东西,格式可能对于您打算使用的操作系统无效。

您需要在Windows 8计算机中识别DateTime的文化并参考此link [< a href =http://msdn.microsoft.com/en-us/library/5hh873ya(v=vs.90).aspx\"target =_ blanktitle =New Window> ^ ] for将日期时间转换为该文化。



希望这会对你有所帮助。



问候,

RK



If you have value then its should be something with Datetime culture, the format may be invalid to the OS that you are intend to use.
You need to identify the culture of DateTime in your windows 8 machine and refer this link[^] for converting the datetime to that culture.

Hope this helps you a bit.

Regards,
RK


这篇关于如何解决“String未被识别为有效的DateTime”。在asp.net只在Windows 8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆