Showing posts with label password. Show all posts
Showing posts with label password. Show all posts

Saturday, March 31, 2012

System.FormatException: Input string was not in a correct format

I am getting above error

// Validate input
if ((userId.Trim() == string.Empty) || (password.Trim() == string.Empty))
return null;

// Get an instance of the account DAC using the DACFactory
IUserAccount dac = CData.DACFactory.FDACUserAccount.Create();

//On this line i am getting error.userId and Password are strings
UserAccountInfo userAccount = dac.Login(userId , password);
return userAccount;

Please sort out my problemI have made three assemblies. 1 is calling 2nd and 2nd is calling 3rd.
now when i call methods of 3rd from 1st through 2nd one i get "System.FormatException: Input string was not in a correct format" on every string manipulation. Even if it is throwing exceptions in string formats it gives that exception
When you use the Trim method, it expects the variable to be a string. When your variable is null, the Trim method would throw that FormatException. So you should rewrite your code to test your variable again null instead.
Ex:
<code>
if( userID == null )
{
//do something here
}

Saturday, March 24, 2012

System.Net.Mail.SmtpException

My webserver does not have smtp on it but I'm still able to relay email to my email server with user name and password, my first question is that the dotnet is using an API that's built into server to relay?

Also email stopped working a day ago with error messageSyntax error, command unrecognized. The server response was: 5.1.0 Dropping connection due to an error on this server . Could this error be caused by the internal process dotnet uses to relay not working?

The 5.1.0 error is usually on the remote SMTP server and the error is propogated back to you. Does the server you relay to allow relays?

You're not relaying. System.Net.Mail simply sends the message to the defined SMTP server. Your error is a SMTP error, check the logs on the SMTP server to see what is happening, if you can. A 5.1.0 is a Sender Denied error, which most likely means you now need to use authentication. Checkwww.systemnetmail.com for help and samples.

Jeff


Still not getting this working getting, any help would be appreciated.

System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

Line 88: try
Line 89: {
Line 90: client.Send(message);
Line 91: Response.Redirect("RequestAccepted.aspx");
Line 92: }
Source File:d:\Inetpub\KPClient\ContactUS.aspx.cs Line:90

Stack Trace:

[SocketException (0x274d): No connection could be made because the target machine actively refused it] System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +1001874 System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +33 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +431[WebException: Unable to connect to the remote server] System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +1447464 System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +190 System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21 System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +318 System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +227 System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +316 System.Net.Mail.SmtpClient.GetConnection() +42 System.Net.Mail.SmtpClient.Send(MailMessage message) +1485


This turned out to be a bad router change that was not documented.