无法连接c#中的远程服务器,并且在移动设备上发送sms时对象引用未设置为对象的实例

无法连接c#中的远程服务器,并且在移动设备上发送sms时对象引用未设置为对象的实例,c#,C#,我正在尝试从移动用户的c#windows应用程序发送短信。虽然 使用此代码,将显示以下错误: 1) 无法连接远程服务器 2) 对象引用未设置为实例对象 那么,在错误消息“无法连接远程服务器”中,您不清楚什么?这不是代码问题,而是网络连接有问题。我怀疑第二个错误来自第一个错误。嗨,安迪,谢谢你的快速回复。事实上,我无法连接到服务器和发送短信给给定的暴徒。没有\即使网速很好,实际上我想从c#应用程序发送手机短信。请在此方面提供帮助,或者您有任何其他方法使用第三方API进行访问。您是否尝试通过web浏

我正在尝试从移动用户的c#windows应用程序发送短信。虽然 使用此代码,将显示以下错误:

1) 无法连接远程服务器

2) 对象引用未设置为实例对象


那么,在错误消息“无法连接远程服务器”中,您不清楚什么?这不是代码问题,而是网络连接有问题。我怀疑第二个错误来自第一个错误。嗨,安迪,谢谢你的快速回复。事实上,我无法连接到服务器和发送短信给给定的暴徒。没有\即使网速很好,实际上我想从c#应用程序发送手机短信。请在此方面提供帮助,或者您有任何其他方法使用第三方API进行访问。您是否尝试通过web浏览器访问此url?感谢rogalski,我尝试并发现此JSON值{“errors”:[{“code”:3,“message”:“Invalid login details”}],“status”:“failure”}看起来像是无效凭据
try{
        String result;
        string userName = "abc@gmail.com";
        string hash = "hashkey";
        string numbers = "911234567890"; // in a comma seperated list
        string message = "This is your message";
        string sendermo = "TXTLCL";

        String url = "http://api.textlocal.in/send/?username=" + userName + "&hash=" + hash + "&numbers=" + numbers + "&message=" + message + "&sender=" + sendermo;
        //refer to parameters to complete correct url string

        StreamWriter myWriter = null;
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);

        objRequest.Method = "POST";
        objRequest.ContentLength = Encoding.UTF8.GetByteCount(url);
        objRequest.ContentType = "application/x-www-form-urlencoded";
        try
        {
            myWriter = new StreamWriter(objRequest.GetRequestStream());
            myWriter.Write(url);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        finally
        {
            myWriter.Close();
        }

        HttpWebResponse objResponse = HttpWebResponse)objRequest.GetResponse();

        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
        {
            result = sr.ReadToEnd();
            // Close and clean up the StreamReader
            sr.Close();
        }
             MessageBox.Show(" "+result);
        }
            catch (Exception ec)
        {
        MessageBox.Show(ec.Message);
    }
}