Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
VB
Dim lastRunDateForActiveLock As Date
lastRunDateForActiveLock = Convert.ToDateTime(FirstUseReg.GetValue("runDate"))


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
Posted
Updated 25-Dec-13 18:39pm
v7
Comments
♥…ЯҠ…♥ 25-Dec-13 23:04pm    
You get value from registry?
Aravindba 25-Dec-13 23:10pm    
yes,actually i will use license for my web application,using web i will create registry with value,in one of the key rundate and value is "12/23/2013 12:00:00 AM",if i open web application i need to read this value like "12/23/2013" then i use,but if i convert in windows 8 it show error,but same code work in other os.
♥…ЯҠ…♥ 25-Dec-13 23:14pm    
Okay, can you tell me the registry path that is used to fetch date details from registry in your application?
Aravindba 25-Dec-13 23:17pm    
Try
FirstUseReg = Registry.LocalMachine.OpenSubKey("SOFTWARE\LICENSE\runDate", True)

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

End Try

and then i will use FirstUseReg.GetValue("runDate"),actually i will get date,but it not convert

1 solution

Hi Aravindba,

C#
FirstUseReg = Registry.LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\LICENSE\runDate", True)
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.


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
 
Share this answer
 
v2
Comments
Aravindba 26-Dec-13 0:05am    
hai
i will try like this "lastRunDateForActiveLock = DateTime.ParseExact(FirstUseReg.GetValue("runDate"), "dd/MM/yyyy", CultureInfo.InvariantCultur" but not work
Aravindba 26-Dec-13 0:38am    
hai
if i change datetime format like this 26/12/2013 in registry and in system date then work,but if change datetime format like 12/26/2013 in reg and system not work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900