谁能指出我下面的源代码有什么问题:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
using System.IO.Compression;
using System.Web.Services.Protocols;
using CCBProductionEntityModel;
using ConsoleDebug.NestleWebReference;
using ProtoBuf;
namespace ConsoleDebug
{
class Program
{
static void Main(string[] args)
{
//This is where I get data from and store into a list
CCBProductionEntities et = new CCBProductionEntities();
List<GetNestleData_Result> results = et.GetNestleData(5).ToList();
List<GetNestleData_Result> responseResults;
using (var stream = new MemoryStream())
{
Serializer.Serialize(stream, results);
using (var responseStream = new MemoryStream())
{
responseResults = Serializer.Deserialize<List<GetNestleData_Result>>(responseStream);
}
}
results = responseResults;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < results.Count(); i++)
{
var result = results.ElementAt(i);
sb.Append(result.AssetId + "\t" + result.DeviceId + "\t" + result.InstanceNumber + "\t" + result.Speed + "\t" + result.Heading + "\t" + result.DriverId + "\t" + result.PositionAge + "\t" + result.VehicleRegistrationNum + "\t" + result.GSMAddress + "\t" + result.Odometer + "\t" + result.Latitude + "\t" + result.Longitude + "\t" + result.Altitude + "\t" + result.IgnitionState);
}
Console.WriteLine(sb.ToString());
Console.ReadLine();
}
}
}
尝试运行时,我收到错误消息:Type is not expected, and no contract can be inferred: CCBProductionEntityModel.GetNestleData_Result
我尝试到处搜索例如源代码,但很难找到一个好的和干净的,在使用序列化程序之前我必须定义一些东西吗?如何?谢谢!