Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using windows server 2008r2 server and when i run the application in my machine it shows up this error:
Line 43:             UserBL userBL = new UserBL();
Line 44:             Response.Write(Environment.UserName);
Error line:Line 45:  userBL.PSNo = Convert.ToInt64(Environment.UserName);
Line 46:             //userBL.PSNo = Convert.ToInt64(10604474);
Line 47:             //userBL.Password = ctrLogin.Password;

but the application works fine with windows xp machine.
pls help me out to correct this environment.username error.
thanks in advance
Posted
Updated 8-Jan-13 3:11am
v2

1 solution

Input string was not in a correct format.
It's pretty clear. You are trying to convert some data into a datatype that is incorrect.

Based on the line you mention, this means that username is not of type Int64. Further, AFAIK, Environment.Username is of type String. Thus, when you try to convert it into Int64, you get an error. It's a string, not an integer.

Refer: MSDN: Environment.UserName Property [^]
 
Share this answer
 
v3
Comments
fjdiewornncalwe 8-Jan-13 10:39am    
+5.
Sandeep Mewara 8-Jan-13 10:43am    
Thanks :)

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