Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# VB ASP.NET
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
Edited 8-Jan-13 3:11am
v2

1 solution

Rate this: bad
good
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 [^]
  Permalink  
v3
Comments
Marcus Kramer at 8-Jan-13 10:39am
   
+5.
Sandeep Mewara at 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
0 Sergey Alexandrovich Kryukov 345
1 _Amy 210
2 Peter Leow 175
3 Nirav Prabtani 167
4 Andreas Gieriet 160
0 OriginalGriff 7,540
1 Sergey Alexandrovich Kryukov 6,597
2 Maciej Los 3,849
3 Peter Leow 3,653
4 CHill60 2,712


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2014
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