当前位置: 代码迷 >> C# >> 小弟我在线程中用ef写sql数据库的exe文件放到服务器就失败呢
  详细解决方案

小弟我在线程中用ef写sql数据库的exe文件放到服务器就失败呢

热度:40   发布时间:2016-05-05 04:02:28.0
我在线程中用ef写sql数据库的exe文件放到服务器就失败呢?

提示:未将对象引用设置到对象的实例
代码:
private bool SaveData(float[] dispVal, ClientDto client) //8通道 0:地址 1:03/06 du/xie 2:长度 2对应两个数据位3\4 数据 6/7:校验和

{
        //保存, 判断通道,没有则添加
        ExtHost h;
        BLL.ExtHostBLL host = new ExtHostBLL();

        h = host.GetHostByHostcode(client.HostId);

        int channelIndex = 1;
        string channelId = "";
        foreach (decimal val in dispVal)
        {

            if (!host.ExistChannel("通道" + channelIndex, h.Id, out channelId))
            {
                channelId = Common.Result.GetNewId();
                host.AddChannel(channelId, "通道" + channelIndex, client.HostId);

            }
            host.AddChannelData(Common.Result.GetNewId(), channelId, val);
            channelIndex++;

        }
        return true;

    }
------解决思路----------------------
未将对象引用设置到对象的实例  这是错误是使用了空引用。

用debug版运行下,注意pdb文件也deploy,并且显示完整的exception信息,里面会包含行号。附近的代码,在使用引用前都判断是不是Null.
------解决思路----------------------
你看一眼你异常的堆栈信息,确定那句话报错,加个断点,一个个变量看哪个为空;
没法远程调试就写详细的log
  相关解决方案