ApplicationManager.SensorInfoAndDataList sensorAndData = appManager.GetDataByPolygonQuery(polygon, polygon, "", types);
            if (sensorAndData != null)
            {
                int length = Math.Min(sensorAndData.Sensors.Length, sensorAndData.Data.Length);
                for (int i = 0; i < length; i++)
                {
                    if (sensorAndData.Sensors[i] != null)
                        Console.Write(i + " - Sensor:"
                                          + sensorAndData.Sensors[i].sensorName + ","
                                          + sensorAndData.Sensors[i].publisherName + ";");
                    if (sensorAndData.Data[i] != null && sensorAndData.Data[i].Timestamps != null)
                        Console.Write(" Data" + i + ":"
                                          + sensorAndData.Data[i].Timestamps[0] + ","
                                          + sensorAndData.Data[i].Data[0] + ";");
                    Console.WriteLine();
                }
            }
这是我写的一段代码,运行后总是在红色语句那里显示:未处理的SOAPexception,具体如下
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
   at AppLib.AppManager.GetUniqueList(List`1 data, List`1 sensors, Boolean& isUniqueStations) in C:\SenseWeb\src\netembed\NetEmbed\SenseWebV3.1.1\Coordinator\AppLib\AppManager.cs:line 152
   at AppLib.AppManager.GetFinalListofSensors(List`1& data, List`1& sensors) in C:\SenseWeb\src\netembed\NetEmbed\SenseWebV3.1.1\Coordinator\AppLib\AppManager.cs:line 198
   at AppLib.AppManager.GetDataByPolygonQueryWithAuthentication(String userName, Guid passCode, PointF[] polygon, PointF[] viewport, String searchTerms, Int32[] sensorTypeIDs) in C:\SenseWeb\src\netembed\NetEmbed\SenseWebV3.1.1\Coordinator\AppLib\AppManager.cs:line 133
   at AppLib.AppManager.GetDataByPolygonQuery(PointF[] polygon, PointF[] viewport, String searchTerms, Int32[] sensorTypeIDs) in C:\SenseWeb\src\netembed\NetEmbed\SenseWebV3.1.1\Coordinator\AppLib\AppManager.cs:line 71
   at Service.GetDataByPolygonQuery(PointF[] polygon, PointF[] viewport, String searchTerms, Int32[] sensorTypeIDs)
   --- End of inner exception stack trace ---
这是怎么回事呢 很着急 在线等

解决方案 »

  1.   

    System.ArgumentOutOfRangeException: Length cannot be less than zero.
    Parameter name: length 应该告诉你了,长度不能小于0。
    AppLib.AppManager.GetUniqueList(List`1 data, List`1 sensors, Boolean& isUniqueStations) in C:\SenseWeb\src\netembed\NetEmbed\SenseWebV3.1.1\Coordinator\AppLib\AppManager.cs:line 152
    看看你这个AppManager.cs:line 152地方或者附近的地方,一般是你对一个长度为0的字符串进行某些操作。是不是有SubString或者其他什么方法。把你的AppManager.cs贴出来了。
      

  2.   

                ApplicationManager.Service appManager = new ApplicationManager.Service(); 
              
                string userName = "name";
                string passwd = "password";
                UserManager.Service userManager = new UserManager.Service();
                string passCode = userManager.GetPassCode(userName, passwd).ToString();
    这是前面变量的定义
      

  3.   

    ApplicationManager.SensorInfoAndDataList sensorAndData = appManager.GetDataByPolygonQuery(polygon, polygon, "", types); 
    我把后面的代码全都注释了以后 仍然出现以上的情况