c# - 输入字符串的格式不正确

标签 c# .net winforms web-services soap

我有两个具有完全相同接口(interface)的 Web 服务函数(从 C#/Winform 应用程序调用):

string[] f1(int, string[])string[] f2(int, string[])

我要向其发送完全相同的数据。当我调用 f1 时,它工作正常并返回一个字符串 [],但是,当我调用 f2 时,我得到一个 SOAPException 说“输入字符串的格式不正确”。

什么可能导致一个工作而另一个不工作?

    private void backgroundWorkerUploadNew_DoWork(object sender, DoWorkEventArgs e)
    {
        List<String> submittedList = new List<String>();
        StreamReader reader = new StreamReader(this.textBoxFilename.Text);
        String data;

        while ((data = reader.ReadLine()) != null)
        {
            submittedList.Add(data);
        }
        reader.Close();
        // Send array of handset names to service
        int channelId = 0;
        string[] listToSubmit = submittedList.ToArray();
        channelId = AppStatus.CurrentChannel.ChannelID;
        String[] newHandsetsList = service.Function2(channelId, listToSubmit);
        ...
    }

网络服务方法

public List<String> Function2(int integer, List<String> strings)
{
    List<String> newList = new List<string>();
    DataTable tempDt = null;
    foreach (String s in strings)
    {
        String q = @"** SOME QUERY **";
        tempDt = Database.RunSql(q);
        ...
    }
    return newList;
}

最佳答案

该消息来自 Parse 方法(对于数字类型、DateTime 等)。如果计算机使用不同的文化,正确的格式就会不同。如果这是问题所在,您也许可以使用不变区域性来解决它。

关于c# - 输入字符串的格式不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5987329/

相关文章:

.net - Ninject 运行时上下文绑定(bind)

c# - Windows 窗体应用程序中的触摸手势中的触摸位置未正确更新

vb.net - 设置数据源后无法访问 DataGridView 列

c# - 获取列表中每个项目的对象集合(产品)

c# - 如何从 xml 中检索属性

c# - ASP.NET 饼图交互

.net - 最佳开源 LINQ 提供商

c# - 文件夹浏览器对话框

c# - 在 C# 中创建通用接口(interface)

c# - linq查询在字符串列表中分组