Click here to Skip to main content
13,150,471 members (33,949 online)
Rate this:
Please Sign up or sign in to 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 8-Jan-13 3:04am
Updated 8-Jan-13 3:11am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 [^]
Marcus Kramer 8-Jan-13 10:39am
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

Advertise | Privacy |
Web01 | 2.8.170924.2 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100