一个C# xml 序列化错误
一个C# xml 序列化错误
事发现场:
xml序列化的数据中存储的节点数据是
<Module>536870912</Module> (xml文件中)
对应的类属性是
public short Module { get; set; } (C#类中)
序列化的代码:
public static FMDSTimeSeriesDefinitionList Deserialize(string xml)
{
XmlSerializer serializer = new XmlSerializer(typeof(FMDSTimeSeriesDefinitionList));
/* If the XML document has been altered with unknown
nodes or attributes, handle them with the
UnknownNode and UnknownAttribute events.*/
serializer.UnknownNode += new
XmlNodeEventHandler(serializer_UnknownNode);
serializer.UnknownAttribute += new
XmlAttributeEventHandler(serializer_UnknownAttribute);
FMDSTimeSeriesDefinitionList tsList = null;
using (StringReader sr = new StringReader(xml))
{
try
{
tsList = (FMDSTimeSeriesDefinitionList)serializer.Deserialize(sr);
}
catch (Exception ex)
{
throw ex;
}
}
return tsList;
}
调试时会弹出异常信息:
An unhandled exception of type 'System.InvalidOperationException' occurred in FMTimeSeriesDefinition.exe
Additional information: There is an error in XML document (293, 8).
找到xml文件的293行第8列:
292: <Module>536870912</Module>
293: <DurationPeriodsFlag>1</DurationPeriodsFlag>
294: <DecimalFlag>0</DecimalFlag>
是一个"<"标记符,看不出问题,再看前一个节点,突然发现536870912 存入short中,数据溢出。
将short改为int,问题解决。
相关文档:
转自: http://www.cnblogs.com/rentj1/archive/2009/02/23/1396187.html
1 新建类库MyTestDLL
2 右击项目“MyTestDLL”-》属性-》生成-》勾选“为COM互操作注册”
3 打开 AssemblyInfo.cs 文件 修改 [assembly: ComVisible(true)]
4 打开Visual Sutdio 2008 的命令提示行工具输入guidgen.exe 选择D ......
ArrayAdapter adapter =
ArrayAdapter.createfromResource(
this,
R.array.catalog,
android.R.layout.simple_list_item_1);
this.setListAdapter(adapter);
xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name= ......
本文来自CSDN博客:http://blog.csdn.net/jinjazz/archive/2008/07/14/2650506.aspx
将oledb读取的excel数据快速插入的sqlserver中,很多人通过循环来拼接sql,这样做不但容易出错而且效率低下,最好的办法是使用bcp,也就是System.Data.SqlClient.SqlBulkCopy 类来实现。不但速度快,而且代码简单,下面测试代码导入一个6 ......
我写的第一个程序中写XML的代码执行速度有些问题,改了一下,现在有所改善。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Data.SqlClient;
......
额 这两天继续写那个 抽奖程序。。
先是 写好了 按几等奖 几个人的 界面可以抽出来了号码于是在找了winform的皮肤界面。还不错。。
给 assistant杨看然后又给我说 没滚动的效果 看起来不好 没抽奖的刺激感。
然后再到网上找了个 滚动效果的 FLASH。。
接着找了一天终于知道了 FLASH 的编程语言 如何简单修改。。。 ......