C# 代码错误,未将对象引用设置到对象的实例

private void btnSend_Click(object sender, EventArgs e)
{
if (cbTimeSend.Checked)
{
tmSend.Enabled = true;
}
else
{
tmSend.Enabled = false;
}

        if (!sp1.IsOpen) //如果没打开
        {
            MessageBox.Show("请先打开串口!", "Error");
            return;
        }
       // string strSend = null;
        String strSend = txtSend.Text.ToString();

            if (radio1.Checked == true) //“HEX发送” 按钮 
            {
                //处理数字转换
                string sendBuf = strSend;
                string sendnoNull = sendBuf.Trim();
                string sendNOComma = sendnoNull.Replace(',', ' ');    //去掉英文逗号
                string sendNOComma1 = sendNOComma.Replace(',', ' '); //去掉中文逗号
                string strSendNoComma2 = sendNOComma1.Replace("0x", "");   //去掉0x
                strSendNoComma2.Replace("0X", "");   //去掉0X
                string[] strArray = strSendNoComma2.Split(' ');

                int byteBufferLength = strArray.Length;
                for (int i = 0; i < strArray.Length; i++)
                {
                    if (strArray[i] == "")
                    {
                        byteBufferLength--;
                    }
                }
                // int temp = 0;
                byte[] byteBuffer = new byte[byteBufferLength];
                int ii = 0;
                for (int i = 0; i < strArray.Length; i++)        //对获取的字符做相加运算
                {

                    Byte[] bytesOfStr = Encoding.Default.GetBytes(strArray[i]);

                    int decNum = 0;
                    if (strArray[i] == "")
                    {
                        //ii--;     //加上此句是错误的,下面的continue以延缓了一个ii,不与i同步
                        continue;
                    }
                    else
                    {
                        decNum = Convert.ToInt32(strArray[i], 16); //atrArray[i] == 12时,temp == 18 
                    }

                    try    //防止输错,使其只能输入一个字节的字符
                    {
                        byteBuffer[ii] = Convert.ToByte(decNum);
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show("字节越界,请逐个字节输入!", "Error");
                        tmSend.Enabled = false;
                        return;
                    }

                    ii++;
                }
                sp1.Write(byteBuffer, 0, byteBuffer.Length);
            }
            else        //以字符串形式发送时 
            {
                sp1.WriteLine(txtSend.Text);    //写入数据
            }

    }

void sp1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
//输出当前时间
DateTime dt = DateTime.Now;
txtReceive.Text += dt.GetDateTimeFormats('f')[0].ToString() + "\r\n";
txtReceive.SelectAll();
txtReceive.SelectionColor = Color.Blue; //改变字体的颜色
try
{
byte[] receivedData = new byte[sp1.BytesToRead]; //创建接收字节数组
sp1.Read(receivedData, 0, receivedData.Length); //读取数据
if (receivedData.Length == 0)
return;
sp1.DiscardInBuffer(); //清空SerialPort控件的Buffer
if (receivedData.Length == 3 && receivedData[0] == 0xFF && receivedData[1] == _totalBytes[1] &&
receivedData[2] == 0x00)

            {
                //_totalBytes[1] = Convert.ToByte(_totalBytes[1] == 0xB5 ? 0xB6 : 0xB5);
                _totalBytes[1] = Convert.ToByte(_totalBytes[1] == 0xB6 ? 0xB5 : 0xB6);
                //_size += _totalBytes[1] == 0xB5 ? 512 : 0;
                _size += _totalBytes[1] == 0xB6 ? 512 : 0;
                SendBytes(false);
            }
            else
            {
                //发送失败
            }
            string strRcv = null;
            if (rdSendStr.Checked)
            {
                strRcv = sp1.Encoding.GetString(receivedData);
            }
            else
            {
                //int decNum = 0;//存储十进制
                for (int i = 0; i < receivedData.Length; i++) //窗体显示
                {

                    strRcv += receivedData[i].ToString("X2");  //16进制显示
                }
            }
            txtReceive.Text += strRcv + "\r\n";
        }
        catch (System.Exception ex)
        {
            MessageBox.Show(ex.Message, "出错提示");
            txtSend.Text = "";
        }
    }
 串口发送一段指定的字符串,串口接收,串口收到回复消息,提示出错。未将对象引用设置到对象的实例

图片说明





c#

17个回答

判断条件改为:
if(treeView1.SelectedNode==null || treeView1.SelectedNode.Tag ==null)
{

//……
}
原因:
SelectedNode 有可能为空值

SelectedNode 有可能为空值

检查一下配置串口或者SelectedNode 有可能为空值

判断条件改为:
if(treeView1.SelectedNode==null || treeView1.SelectedNode.Tag ==null)
{

//……
}
原因:
SelectedNode 有可能为空值

SelectedNode 有可能为空值
加断点慢慢调试看看哪里有问题

打个断点一步步的调试,直到报错的哪一行,想想为什么为空

判断条件改为:
if(treeView1.SelectedNode==null || treeView1.SelectedNode.Tag ==null)
{

//……
}
原因:
SelectedNode 有可能为空值

共17条数据 首页 2
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
关于C#“未将对象引用设置到对象的实例”的几个问题。

我是一个超级小白,也是第一次提问,还望各位大佬指教。 首先,我编写了一个WPF窗体和一个TextBox.ID为"aa1"的“TextChanged", 想达到如下目的: 当“aa1”的text值发生改变后,立即实时的将"aa1"的text值赋给TextBox.ID为“aa2”的text。 但是调试时在“aa2.Text = Convert.ToString(x1);”这句话提示“System.NullReferenceException:“未将对象引用设置到对象的实例。” 个人想法是这样的:因为这是“aa1”的TextChanged,所以C#可以知道“aa1”是什么,但是对“aa2”没有说明,导致C#不知道这个“aa2”是什么,问题可能是出在“实例化”与“引用”之间。 想请问各位大佬: 1.对于这种情况我应该怎样去修改? 2.在“未将对象引用设置到对象的实例”这句话中,“对象”指的是什么? 代码片段如下: ``` private void Aa1_TextChanged(object sender, TextChangedEventArgs e) { double x1 = Convert.ToDouble(aa1.Text); aa2.Text = Convert.ToString(x1); } ``` 谢谢。

C# 代码明明有获取到数据,为什么还会出现错误“未将对象引用设置到实例”

public TheCustomCheckDetailObj GetTheCustomCheckDetail(int TheCustomCheck) { using (SqlConnection con = new SqlConnection(_connectionString)) { con.Open(); SqlCommand cmd = new SqlCommand("OGetTheCustomCheckDetail", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@TheCustomCheck", SqlDbType.Int); cmd.Parameters["@TheCustomCheck"].Value = TheCustomCheck; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { obj.CurrentCustomDetailObj.CompanyName = Convert.ToString(reader["CompanyName"]); obj.CurrentCustomDetailObj.CompanyPart = Convert.ToString(reader["CompanyPart"]); obj.CurrentCustomDetailObj.CompanyWebsite = Convert.ToString(reader["CompanyWebsite"]); obj.CurrentCustomDetailObj.CustomName = Convert.ToString(reader["CustomName"]); obj.CurrentCustomDetailObj.CustomCellphone = Convert.ToString(reader["CustomCellphone"]); obj.CurrentCustomDetailObj.CustomPhone = Convert.ToString(reader["CustomPhone"]); obj.CurrentCustomDetailObj.CustomFenji = Convert.ToString(reader["CustomFenji"]); obj.CurrentCustomDetailObj.QQorMSN = Convert.ToString(reader["QQorMSN"]); obj.CurrentCustomDetailObj.Email = Convert.ToString(reader["Email"]); obj.CurrentCustomDetailObj.BusinessID = Convert.ToInt32(reader["BusinessID"]); obj.CurrentCustomDetailObj.ProvinceID = Convert.ToInt32(reader["ProvinceID"]); obj.CurrentCustomDetailObj.CountryID = Convert.ToInt32(reader["CountryID"]); obj.CurrentCustomDetailObj.CityID = Convert.ToInt32(reader["CityID"]); obj.CurrentCustomDetailObj.Address = Convert.ToString(reader["Address"]); obj.CurrentCustomDetailObj.PS = Convert.ToString(reader["PS"]); obj.InCheckCustomDetailObj.CompanyName = Convert.ToString(reader["OldCompanyName"]); obj.InCheckCustomDetailObj.CompanyPart = Convert.ToString(reader["OldCompanyPart"]); obj.InCheckCustomDetailObj.CompanyWebsite = Convert.ToString(reader["OldCompanyWebsite"]); obj.InCheckCustomDetailObj.CustomName = Convert.ToString(reader["OldCustomName"]); obj.InCheckCustomDetailObj.CustomCellphone = Convert.ToString(reader["OldCustomCellphone"]); obj.InCheckCustomDetailObj.CustomPhone = Convert.ToString(reader["OldCustomPhone"]); obj.InCheckCustomDetailObj.CustomFenji = Convert.ToString(reader["OldCustomFenji"]); obj.InCheckCustomDetailObj.QQorMSN = Convert.ToString(reader["OldQQorMSN"]); obj.InCheckCustomDetailObj.Email = Convert.ToString(reader["OldEmail"]); obj.InCheckCustomDetailObj.BusinessID = Convert.ToInt32(reader["OldBusinessID"]); obj.InCheckCustomDetailObj.ProvinceID = Convert.ToInt32(reader["OldProvinceID"]); obj.InCheckCustomDetailObj.CountryID = Convert.ToInt32(reader["OldCountryID"]); obj.InCheckCustomDetailObj.CityID = Convert.ToInt32(reader["OldCityID"]); obj.InCheckCustomDetailObj.Address = Convert.ToString(reader["OldAddress"]); obj.InCheckCustomDetailObj.PS = Convert.ToString(reader["OldPS"]); } reader.Close(); con.Close(); return obj; } }

话说在MVC未将对象引用到实例这个一般是什么导致的呢

如题: “/”应用程序中的服务器错误。 未将对象引用设置到对象的实例。 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。 源错误: ``` 行 2: @{ 行 3: ViewBag.Title = "添加会员卡"; 行 4: var member = (Member)Session["member"]; 行 5: } 行 6: <ol class="breadcrumb"> ```

System.NullReferenceException: 未将对象引用设置到对象的实例

在学习微软认知服务,用C#编写了一个简单的接口,但是出现了“未将对象引用设置到对象的实例 (System.NullReferenceException)”这个问题。在网上查了原因,好像有以下几种说法: “System.NullReferenceException: 未将对象引用设置到对象的实例”问题可能原因如下: 1、ViewState 对象为Null。 2、DateSet 空。 3、sql语句或Datebase的原因导致DataReader空。 4、声明字符串变量时未赋空值就应用变量。 5、未用new初始化对象。 6、Session对象为空。 7、对控件赋文本值时,值不存在。 8、使用Request.QueryString()时,所获取的对象不存在,或在值为空时未赋初始值。 9、使用FindControl时,控件不存在却没有做预处理。 10、重复定义造成未将对象引用设置到对象的实例错误. 第一次接触C#,看不出来究竟属于哪一类错误,求问各位大神这个错误应该怎么修正。编译器提示的错误在代码中注释出来了 以下附小弟源码: ``` using System.Collections.Generic; using System.Net.Http; using System.Text; using Newtonsoft.Json; using System; using System.Net.Http.Headers; using System.Web; public class Program { private const string ApiKey = "804e4631f32a421b8cf8066ca2d54fb0"; private const string DescribeImageApiUrl = "https://api.projectoxford.ai/vision/v1.0/describe?maxCandidates=3"; private const string ContentType = "application/json"; public static void Main(string[] args) { var imageUrls = new[] { "http://i.imgur.com/OJ6lzhz.jpg", "http://i.imgur.com/OV80Pr8.jpg" }; foreach(var imageUrl in imageUrls) { var response = DescribeImage(imageUrl); Console.WriteLine("Image: {http://img.taopic.com/uploads/allimg/110910/2316-110910124R147.jpg}"); Console.WriteLine("Descriptions:"); foreach (var caption in response.Description.Captions)//提示错误出现在这一行 { Console.WriteLine(caption.Text); } Console.WriteLine(new string('-', 5)); } Console.Read(); } private static DescribeImageResponse DescribeImage(string imageUrl) { var client = new HttpClient(); client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", ApiKey); var imageJson = new { url = imageUrl }; var response = client.PostAsync( DescribeImageApiUrl, new StringContent( JsonConvert.SerializeObject(imageJson), Encoding.UTF8, ContentType)).Result; var content = response.Content.ReadAsStringAsync().Result; return JsonConvert.DeserializeObject<DescribeImageResponse>(content); } private class DescribeImageResponse { public DescribeImageResponseDescription Description { get; set; } public string RequestId { get; set; } public DescribeImageResponseMetadata Metadata { get; set; } } private class DescribeImageResponseDescription { public List<string> Tags { get; set; } public List<DescribeImageResponseDescriptionCaption> Captions { get; set; } } private class DescribeImageResponseDescriptionCaption { public string Text { get; set; } public decimal Confidence { get; set; } } private class DescribeImageResponseMetadata { public double Width { get; set; } public double Height { get; set; } public string Format { get; set; } } } ```

winform程序的Application.Run()抛出异常:“未将对象引用设置到对象的实例“?

##winform程序的Application.Run()抛出异常:“未将对象引用设置到对象的实例“ ![图片说明](https://img-ask.csdn.net/upload/201912/05/1575519266_161353.png) ###下面是调试时感觉出问题的地方: ``` //触发事件 private void MC_Code_SelectedIndexChanged(object sender, EventArgs e) { label8.Text = MC_Code.Text; if (MC_Code.Text == null) return; mc_code = MC_Code.Text; Dept_Code = dept_code.Text; try { Thread thr = new Thread(loadDataGridView); thr.Start(); } catch { } } string mc_code = ""; string Dept_Code = ""; ***#感觉出问题的函数#*** void loadDataGridView() { DataTable table = new DataTable(); //BindingSource bs = new BindingSource(); while (true) { table = getData(mc_code, Dept_Code, Login.Site); if (table == null) return; //BindingSource bs = new BindingSource(); //bs.DataSource = table; //bs.DataMember = "Data"; try { //第一次在下拉列表中选择一个值代码运行到此处,不会出现任何问题;但是当在下拉列表中重新选择值第二次运行到此处时,就会跳转到Application.Run()这个地方抛出异常:“未将对象引用设置到对象的实例“ #this.dataGridView1.DataSource = table;# //this.dataGridView1.DataBindings.Add("Text",bs,""); } catch { return; } Thread.Sleep(60000); } } **不知道具体是什么问题,求大神解决!** ```

运行登录窗体时,显示未将对象引用设置到对象的实例

![图片说明](https://img-ask.csdn.net/upload/202004/08/1586312099_392212.png) using System;https://img-ask.csdn.net/upload/202004/08/1586312099_392212.png using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace StudentInfoSystem { public partial class frmLogin : Form { public frmLogin() { InitializeComponent(); } public static string userName ;//记录登录用户名字//主窗体中使用 public static string userRight;//记录登录用户的权限//主窗体中使用 SqlConnection conn; SqlCommand com; SqlDataAdapter da; SqlDataReader dr; private void frmLogin_Load(object sender, EventArgs e) { try { conn = new SqlConnection("server=(local)\\sqlexpress;integrated security=true;database=StudentBC"); DataSet ds = new DataSet(); da = new SqlDataAdapter("select 用户名称 from 用户表", conn); if (conn.State == ConnectionState.Closed) { conn.Open(); } da.Fill(ds, "用户表"); conn.Close(); cbxUserName.DataSource = ds.Tables["用户表"]; cbxUserName.DisplayMember = "用户名称"; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } private void cbxUserName_SelectedIndexChanged(object sender, EventArgs e)//查询权限值 { try { com = new SqlCommand("select 用户名称,用户权限 from 用户表 where 用户名称='" + cbxUserName.Text + "'", conn); if (conn.State == ConnectionState.Closed) { conn.Open(); } dr = com.ExecuteReader(); if (dr.Read()) { lblUserRight1.Text = dr["用户权限"].ToString(); userRight = lblUserRight1.Text; } dr.Close(); conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } private void btnLogin_Click(object sender, EventArgs e)//可以用读取器类也可以用数据集类实现 { //用数据集类实现 try { da = new SqlDataAdapter("select * from 用户表 where 用户名称='" + cbxUserName.Text.Trim() + "' and 用户密码='" + txtUserPwd.Text.Trim() + "'", conn); DataSet ds = new DataSet(); if (conn.State == ConnectionState.Closed) { conn.Open(); } da.Fill(ds, "用户表"); conn.Close(); if (ds.Tables["用户表"].Rows.Count > 0) { userName = cbxUserName.Text; frmMain frmmain = new frmMain(); this.Hide(); frmmain.Show(); } else { MessageBox.Show("用户名或密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUserPwd.Text = ""; cbxUserName.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } //用读取器类实现 private void btnExit_Click(object sender, EventArgs e) { Application.Exit(); } private void frmLogin_FormClosed(object sender, FormClosedEventArgs e) { Application.Exit(); } private void frmLogin_Load_1(object sender, EventArgs e) { } } }

c#调用webservice 服务器无法处理请求。 ---> 未将对象引用设置到对象的实例

“/”应用程序中的服务器错误。 服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ServiceModel.FaultException: 服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。 源错误: 行 128: 行 129: public string[] getWeather(string theCityCode, string theUserID) { 行 130: return base.Channel.getWeather(theCityCode, theUserID); 行 131: } 行 132: 源文件: c:\Users\Administrator\Desktop\WebApplication2\Service References\WeatherWS\Reference.cs 行: 130 堆栈跟踪: [FaultException: 服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10733331 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +336 WebApplication2.WeatherWS.WeatherWSSoap.getWeather(String theCityCode, String theUserID) +0 WebApplication2.WeatherWS.WeatherWSSoapClient.getWeather(String theCityCode, String theUserID) in c:\Users\Administrator\Desktop\WebApplication2\Service References\WeatherWS\Reference.cs:130 WebApplication2.WebForm1.test() in c:\Users\Administrator\Desktop\WebApplication2\WebForm1.aspx.cs:19 WebApplication2.WebForm1.Page_Load(Object sender, EventArgs e) in c:\Users\Administrator\Desktop\WebApplication2\WebForm1.aspx.cs:34 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +92 System.Web.UI.Control.LoadRecursive() +54 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772 namespace WebApplication2 { public partial class WebForm1 : System.Web.UI.Page { protected void test() { WeatherWS.WeatherWSSoapClient w = new WeatherWS.WeatherWSSoapClient("WeatherWSSoap"); string[] infos = new string[50]; if(w.getWeather("天津","")!=null) infos = w.getWeather("天津", " "); } protected void Page_Load(object sender, EventArgs e) { test(); }

报错:未将对象引用设置到对象的实例。下面是代码

public class Temporary { //public string Query_NAME { get; set; } public long Te_TC { get; set; } public long Te_MC { get; set; } public long Te_QC { get; set; } public long Te_WC { get; set; } public long Te_CC { get; set; } public long Te_EC { get; set; } public long Te_PC { get; set; } } private DataServiceCollection<Temporary> temporary; public DataServiceCollection<Temporary> AllTemporary { get { return temporary; } set { if (temporary != value) { temporary = value; this.OnPropertyChanged("AllTemporary"); } } } public object QueryInventoryInfo(string areaId) { if (string.IsNullOrEmpty(areaId)) { areaId = ""; } string locType = "2"; for (int i = 0; i < Areas.Count; i++) { Temporary tem = new Temporary(); tem.Te_TC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId)).LongCount(); tem.Te_MC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId) && c.STATUS.Contains("m")).LongCount(); tem.Te_QC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId) && c.STATUS.Contains("q")).LongCount(); tem.Te_WC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId) && c.STATUS.Contains("w")).LongCount(); tem.Te_CC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId) && c.STATUS.Contains("c")).LongCount(); tem.Te_EC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId) && c.STATUS.Contains("e")).LongCount(); tem.Te_PC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId) && c.STATUS.Contains("p")).LongCount(); if (tem != null) { this.AllTemporary.Add(tem); //此处报错 } } return AllTemporary; }

C#异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

通过MVC 模板创建视图提示此类错误, Model是通过引用EF6框架 ``` 控制器代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Asset.Models; public ActionResult AssetList() { IList<UsbBorrow> UsbBorrows = null; using (AssetEntities db = new AssetEntities()) { db.UsbBorrow.Select(S => S).ToList(); } return View(UsbBorrows); } ``` 视图代码 ``` @model IEnumerable<Asset.Models.UsbBorrow> @{ ViewBag.Title = "AssetList"; } <h2>AssetList</h2> <p> @Html.ActionLink("Create New", "Create") </p> <table class="table"> <tr> <th> @Html.DisplayNameFor(model => model.Type) </th> <th> @Html.DisplayNameFor(model => model.Specification) </th> <th> @Html.DisplayNameFor(model => model.ProductName) </th> <th> @Html.DisplayNameFor(model => model.Num) </th> <th> @Html.DisplayNameFor(model => model.Name) </th> <th> @Html.DisplayNameFor(model => model.ReceiveDate) </th> <th> @Html.DisplayNameFor(model => model.ReturnDate) </th> <th></th> </tr> @foreach (Asset.Models.UsbBorrow UsbBorrow in Model ) { <tr> <td> @Html.DisplayFor(modelItem => UsbBorrow.Type) </td> <td> @Html.DisplayFor(modelItem => UsbBorrow.Specification) </td> <td> @Html.DisplayFor(modelItem => UsbBorrow.ProductName) </td> <td> @Html.DisplayFor(modelItem => UsbBorrow.Num) </td> <td> @Html.DisplayFor(modelItem => UsbBorrow.Name) </td> <td> @Html.DisplayFor(modelItem => UsbBorrow.ReceiveDate) </td> <td> @Html.DisplayFor(modelItem => UsbBorrow.ReturnDate) </td> <td> @Html.ActionLink("Edit", "Edit", new { id= UsbBorrow.ID }) | @Html.ActionLink("Details", "Details", new { id= UsbBorrow.ID }) | @Html.ActionLink("Delete", "Delete", new { id= UsbBorrow.ID }) </td> </tr> } </table> ``` Foreach的时候报错

C#“System.NullReferenceException”类型的未经处理的异常出现。 其他信息: 未将对象引用设置到对象的实例。

``` private void vScrollBar1_Scroll(object sender, ScrollEventArgs e) { foreach (Control gbox in groupBox1.Controls) { if (gbox is VScrollBar) continue; gbox.Location = new Point(gbox.Location.X, (int)gbox.Tag - e.NewValue); } } ``` ``` gbox.Location = new Point(gbox.Location.X, (int)gbox.Tag - e.NewValue); ``` 这句出现错误:System.NullReferenceException”类型的未经处理的异常出现。 其他信息: 未将对象引用设置到对象的实例。 如何解决?

C#萌新遇到了“未将对象引用到对象实例”的问题 希望大佬指点一下

选修的数据库课程用C#做一个前端实现数据库的更改和删除,刚开始学照着书敲了一段代码,运行的时候点击更改就会出现以下错误提示,是我的数据库连接有什么问题吗?求教各位大佬 ![图片说明](https://img-ask.csdn.net/upload/201712/04/1512374007_870907.png)

报错:System.NullReferenceException: 未将对象引用设置到对象的实例。

本人小白,想实现将网页的表写入到word中并导出到本地。但是总是报错“System.NullReferenceException: 未将对象引用设置到对象的实例。 代码部分如下 ```c# protected void docWriteIn2(string TemplatePath) { Aspose.Words.Document Doc = new Aspose.Words.Document(TemplatePath); //载入模板 DocumentBuilder builder = new DocumentBuilder(Doc); NodeCollection tables = Doc.GetChildNodes(NodeType.Table, true); Aspose.Words.Tables.Table table1 = tables[0] as Aspose.Words.Tables.Table; builder.MoveToBookmark("QInspectionDepartId"); builder.Write(QInspectionDepartId.Text.Trim()); builder.MoveToBookmark("Number"); builder.Write(Number.Text.Trim()); builder.MoveToBookmark("QQuantity"); builder.Write(QQuantity.Text.Trim()); builder.MoveToBookmark("QualifiedQuantity"); builder.Write(QualifiedQuantity.Text.Trim()); builder.MoveToBookmark("UqualifiedQuantity"); builder.Write(UqualifiedQuantity.Text.Trim()); builder.MoveToBookmark("PassRate"); builder.Write(PassRate.Text.Trim()); //拿到第一个表格:tableindex=0 Aspose.Words.Tables.Table table2 = tables[1] as Aspose.Words.Tables.Table; //拿到第二行的row模板:rowindex=1 var roww = table2.Rows[1]; if (Session["receiptNumber"]!=null) { var TestInfo = Testinfo.findTestInfo(Session["receiptNumber"].ToString()); ** QInspectionDepartId.Text = contextdb.S_Department_Info.Single(u => u.id == TestInfo.InspectionDepartId).DepartmentName; ** **//**这里肯定是有问题的**,问题出现在上面这一行**** // 第二行QInspectionDepartId.Text = contextdb.S_Department_Info.Single(u => u.id == DepartId).DepartmentName; } var TestBasicInfoList = db.GetTable<K_QCM_TestBasicInfo>(); var TargetListInfoList = db.GetTable<K_QCM_Target_List>(); var node_table = db.GetTable<K_QCM_Score_Tree>(); var TestBasic = from t in TestBasicInfoList where t.SourceNumber == Session["receiptNumber"].ToString() select t; var list = edit2.findReceiptGiven(Session["receiptNumber"].ToString()); var DetailInfoList = db.GetTable<K_W_Receipt_DetailInfo>(); var ReceiptDetail = from t in DetailInfoList where t.ReceiptNumber == Session["receiptNumber"].ToString() select t; int n = 0; foreach (var s in TestBasic) { var TargetDetail = from t in TargetListInfoList where t.ProductNumber == s.InspectionNumber select t; foreach (var i in TargetDetail) { //Button Button1 = new Button(); //Button1.Text = "按钮"; //Button1.ID = i.id.ToString(); //Button1.Click += new System.EventHandler(Button1_Click); int nodeId = db.K_QCM_Score_Tree.Single(u => u.ParentId == 0 && u.SchemaId == i.SchemaId).id; float value = float.Parse(db.K_QCM_Score_Value.Single(u => u.TargetId == i.id && u.NodeId == nodeId).Value.ToString()); K_QCM_Score_Tree selected_node = node_table.Single(h => h.id == nodeId); if (value == 0) { K_P_Product product = edit.findProductFromCoding(i.ProductCode); //复制第2行 var row = roww.Clone(true); //将复制的行插入当前行的上方 table2.Rows.Insert(1 + n, row); //光标移动到:第一个表格的,第1行的第1列的格子里 builder.MoveToCell(1, n + 1, 0, 0); //给序号填充内容 builder.Write((n + 1).ToString()); //给产品名称单元格填充内容 builder.MoveToCell(1, 1 + n, 1, 0); builder.Write(i.ProductName); //给规格型号填充内容 builder.MoveToCell(1, 1 + n, 2, 0); builder.Write(product.Norm); //给单位填充内容 builder.MoveToCell(1, 1 + n, 3, 0); builder.Write(product.Unit); //给数量填充内容 builder.MoveToCell(1, 1 + n, 4, 0); builder.Write("1"); // builder.MoveToCell(1, 1 + n, 5, 0); builder.Write("不合格"); //总计 } else { K_P_Product product = edit.findProductFromCoding(i.ProductCode); //复制第2行 var row = roww.Clone(true); //将复制的行插入当前行的上方 table2.Rows.Insert(1 + n, row); //光标移动到:第一个表格的,第1行的第1列的格子里 builder.MoveToCell(1, n + 1, 0, 0); //给序号填充内容 builder.Write((n + 1).ToString()); //给产品名称单元格填充内容 builder.MoveToCell(1, 1 + n, 1, 0); builder.Write(i.ProductName); //给规格型号填充内容 builder.MoveToCell(1, 1 + n, 2, 0); builder.Write(product.Norm); //给单位填充内容 builder.MoveToCell(1, 1 + n, 3, 0); builder.Write(product.Unit); //给数量填充内容 builder.MoveToCell(1, 1 + n, 4, 0); builder.Write("1"); //检验结果 builder.MoveToCell(1, 1 + n, 5, 0); builder.Write("合格"); } n = n + 1; } } string docName = "word文档"; Doc.Save(docName + ".doc", Aspose.Words.SaveFormat.Doc, SaveType.OpenInWord, Response); } ``` 报错详细如下 未将对象引用设置到对象的实例。 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。 有人知道怎么解决吗?

c#+Arcengine AE 中MapDocument.close报错

![图片说明](https://img-ask.csdn.net/upload/201712/08/1512701134_104112.png) 感觉很奇怪,这个错误之前都没有,代码可以用的,然后突然就不行了

mvc 中action 获取不到session 值

未将对象引用设置到对象的实例。 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。 源错误: 行 110: public ActionResult ImportFail() 行 111: { 行 112: string key = System.Web.HttpContext.Current.Session["KeyId"].ToString(); 行 113: this.Logger.Debug("Hello ImportFail"); 行 114: this.Logger.Debug("keyId" + key); 我在第二action调用第一个action中的session 就说未将对象引用到实例 为什么会报这样的错啊 我改了很久了 求指教啊!!!

非静态的字段、方法或属性“ESRI.ArcGIS.Controls.IMapControlDefault.ActiveView.get”要求对象引用

利用VS和ArcEngine想要写出一段代码,实现导出地图为图片的功能,以下是我在网络上找到可以实现该功能的代码,却出现了问题 ``` ``` private void 导出图片ToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog m_save = new SaveFileDialog(); m_save.Filter = "jpeg图片(*.jpg)|*.jpg|tiff图片(*.tif)|*.tif|bmp图片(*.bmp)|*.bmp|emf图片(*.emf)|*.emf|png图片(*.png)|*.png|gif图片(*.gif)|*.gif"; m_save.ShowDialog(); string Outpath = m_save.FileName; if (Outpath != "") { //分辨率 > double resulotion =**_MapControl.ActiveView_**.ScreenDisplay.DisplayTransformation.Resolution; IExport m_export = null; if (Outpath.EndsWith(".jpg")) { m_export = new ExportJPEG() as IExport; } else if (Outpath.EndsWith(".tig")) { m_export = new ExportTIFF() as IExport; } else if (Outpath.EndsWith(".bmp")) { m_export = new ExportBMP() as IExport; } else if (Outpath.EndsWith(".emf")) { m_export = new ExportEMF() as IExport; } else if (Outpath.EndsWith(".png")) { m_export = new ExportPNG() as IExport; } else if (Outpath.EndsWith(".gif")) { m_export = new ExportGIF() as IExport; } //设置输出的路径 m_export.ExportFileName = Outpath; //设置输出的分辨率 m_export.Resolution = resulotion; tagRECT piexPound; piexPound = **_MapControl.ActiveView_**.ScreenDisplay.DisplayTransformation.get_DeviceFrame(); IEnvelope m_envelope = new Envelope() as IEnvelope; m_envelope.PutCoords(piexPound.left, piexPound.bottom, piexPound.right, piexPound.top); //设置输出的IEnvelope m_export.PixelBounds = m_envelope; ITrackCancel m_trackCancel = new CancelTracker(); //输出的方法 **_MapControl.ActiveView_**.Output(m_export.StartExporting(), (short)resulotion, ref piexPound, **_MapControl.ActiveView_**.Extent, m_trackCancel); m_export.FinishExporting(); } } ``` ``` 四个问题,都是MapControl.ActiveView的问题,代码中已加粗斜体显示,问题一致是“非静态的字段、方法或属性“ESRI.ArcGIS.Controls.IMapControlDefault.ActiveView.get”要求对象引用”的问题。

webconfig如何配置实现所有错误页跳转到登录页面

我是把用户的登录名还有密码都保存到了session里面,但是现在出现问题就是session 一旦过期,后台就会出现未将对象引用设置到对象的实例,请问如何解决这个问题。。

用dataAdapter.update更新DataGridView中的数据,代码总是抛出异常说 dataAdapter 是 null,该怎么修改?

用dataAdapter.update更新DataGridView中的数据,代码总是抛出异常System.NullReferenceException:“未将对象引用设置到对象的实例。” dataAdapter 是 null,该怎么修改? 这里是详细代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.SqlClient; namespace 项目二 { public partial class Form1 : Form { SqlDataAdapter dataAdapter; DataSet dataSet; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string connString = "Data Source = (local);Initial Catalog = Mybookshop;User ID = sa;pwd = 123456"; SqlConnection con = new SqlConnection(connString); string sql = "SELECT * FROM book1"; SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con); DataSet dataSet; dataSet = new DataSet(); dataAdapter.Fill(dataSet, "Mydata"); dataGridView1.DataSource = dataSet.Tables[0]; } private void button2_Click(object sender, EventArgs e) { SqlCommandBuilder builder = new SqlCommandBuilder(dataAdapter); dataAdapter.Update(dataSet, "Mydata"); } } } ![图片说明](https://img-ask.csdn.net/upload/201912/06/1575634228_121330.png) 输入数据点击更新后错误显示为 ![图片说明](https://img-ask.csdn.net/upload/201912/06/1575634258_789589.png)

c#异步通信代码错误问题

public void ConnectCallback(IAsyncResult ar) { Socket client = (Socket)ar.AsyncState; client.EndConnect(ar); bool connect_flag = false; connect_flag = true; ManualResetEvent connectDone = new ManualResetEvent(false); //连接的信号 connectDone.Set(); } //vs的这段代码中 ,bool connect_flag的connect_flag报了一个警告错误,变量connect_flag已赋值,但是其值从未使用过。如何修改? public static MODEL.DataSourceVersionQuery BrowseDataSource_QueryVersionData() { MODEL.DataSourceVersionQuery result = new MODEL.DataSourceVersionQuery(); //获取数据包 string strPacket = BrowseDataSource_PrepareVersionPacket(); //向服务端提交查询版本信息 string str = DAL.socket.GetSocketData(strPacket); //DAL.socket.GetSocketData(strPacket) vs报了一个错误,非静态字段、方法或属性DAL.socket.GetSocketData(string)“要求对象引用。如何修改? 还有这个错误![图片说明](https://img-ask.csdn.net/upload/201509/16/1442412249_893824.png) 另外我想把DAL中的socket.cs的 public byte[] bytesReceived { get; set; }这段移动到Model中而不报错要如何修改? DAL中socket完整代码如下: using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading.Tasks; using System.ComponentModel; using System.Data; using System.Windows.Forms; using System.Threading; namespace DAL { /// <summary> /// Socket接口 /// </summary> class socket { //Socket public Socket clientSocket; /// <summary> /// socket连接 /// </summary> /// <returns> /// true 成功 /// false 失败 /// </returns> public bool SocketConnect() { byte[] bytesReceived = new byte[256]; ManualResetEvent connectDone = new ManualResetEvent(false); //连接的信号 ManualResetEvent sendDone = new ManualResetEvent(false); //发送结束 //从配置文件获取IP string SocketIP = DAL.Common.ReadConfigString("Recover", "IP"); //从配置文件获取端口 int SocketPort = Convert.ToInt32(DAL.Common.ReadConfigString("Recover", "Port")); //创建IP地址 IPAddress IP = IPAddress.Parse(SocketIP); try { //创建socket实例 clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //创建网络端点 IPEndPoint ipEnd = new IPEndPoint(IP, SocketPort); //与目标终端连接 clientSocket.BeginConnect(ipEnd, new AsyncCallback(ConnectCallback), clientSocket);//调用回调函数 connectDone.WaitOne(); if (clientSocket.Connected) { return true; } else { return false; } } catch (Exception e) { string strError = ""; strError += "\r\n SocketIP = " + SocketIP.ToString(); strError += "\r\n SocketPort = " + SocketPort.ToString(); DAL.Common.WriteErrorLog(e, strError); return false; } } /// <summary> /// 异步连接的回调函数 /// </summary> /// <param name="ar"></param> public void ConnectCallback(IAsyncResult ar) { Socket client = (Socket)ar.AsyncState; client.EndConnect(ar); bool connect_flag = false; connect_flag = true; ManualResetEvent connectDone = new ManualResetEvent(false); //连接的信号 connectDone.Set(); } /// <summary> /// Socket发送数据 /// </summary> /// <param name="strSend"> /// 数据的内容 /// </param> public void SocketSend(string strSend) { Socket clientSocket; //发送创建套接字 int length = strSend.Length; Byte[] bytesSent = new byte[length]; clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { bytesSent = System.Text.Encoding.Default.GetBytes(strSend); //将字符串指定到指定Byte数组 clientSocket.BeginSend(bytesSent, 0, bytesSent.Length, 0, new AsyncCallback(SendCallback), clientSocket); //异步发送数据 ManualResetEvent sendDone = new ManualResetEvent(false);//发送结束 sendDone.WaitOne(); } catch (Exception e) { string strError = ""; DAL.Common.WriteErrorLog(e, strError); } } public void SendCallback(IAsyncResult ar) //发送的回调函数 { ManualResetEvent sendDone = new ManualResetEvent(false); //发送结束 Socket client = (Socket)ar.AsyncState; int bytesSend = client.EndSend(ar); //完成发送 sendDone.Set(); } /// <summary> /// Socket接收数据 /// </summary> /// <returns> /// 收到的数据 /// </returns> public string SocketReceive() { string result = ""; try { MemoryStream stream = new MemoryStream(); Byte[] bytesReceived = new Byte[256]; clientSocket.BeginReceive(bytesReceived, 0, bytesReceived.Length, 0, new AsyncCallback(ReceiveCallback), clientSocket); ManualResetEvent sendDone = new ManualResetEvent(false); //发送结束 sendDone.WaitOne(); } catch (Exception e) { string strError = ""; DAL.Common.WriteErrorLog(e, strError); } return result; } public void ReceiveCallback(IAsyncResult ar) { Socket client = (Socket)ar.AsyncState; //获取句柄 int bytesread = client.EndReceive(ar); if (bytesread > 0) { clientSocket.BeginReceive(bytesReceived, 0, bytesReceived.Length, 0, new AsyncCallback(ReceiveCallback), client); string content = Encoding.ASCII.GetString(bytesReceived, 0, bytesReceived.Length); } else { ManualResetEvent readDone = new ManualResetEvent(false); //读信号 readDone.Set(); } } /// <summary> /// Socket通信 /// </summary> /// <param name="strSend"> /// 发送的信息 /// </param> /// <returns> /// 包体的内容 /// </returns> public string GetSocketData(string strSend) { string strDatas = ""; string strResult = ""; string strExtLength = ""; try { //Socket连接 SocketConnect(); //发送信息 SocketSend(strSend); //接收服务器的信息 strResult = SocketReceive(); //获取扩展信息的长度 strExtLength = strResult.Substring(16, 12); int ExtLength = Convert.ToInt32(strExtLength); //扩展信息,暂不使用 //string strExtInfo = strResult.Substring(32, ExtLength); //获取包体的内容 strDatas = strResult.Substring(ExtLength + 32); //strDatas = decodedString; } catch (Exception e) { string strError = ""; strError += "\r\n strResult = " + strResult; strError += "\r\n strExtLength = " + strExtLength; DAL.Common.WriteErrorLog(e, strError); strDatas = ""; } return strDatas; } public string SocketReceiveFile(string FileName) { string result = ""; try { MemoryStream streamPacketLength = new MemoryStream(); Byte[] bytesPacketLength = new Byte[16]; clientSocket.Receive(bytesPacketLength, bytesPacketLength.Length, 0); streamPacketLength.Write(bytesPacketLength, 0, bytesPacketLength.Length); result = System.Text.Encoding.Default.GetString(streamPacketLength.ToArray()); int PacketLength = Convert.ToInt32(result); streamPacketLength.Close(); MemoryStream streamExtLength = new MemoryStream(); Byte[] bytesExtLength = new Byte[12]; clientSocket.Receive(bytesExtLength, bytesExtLength.Length, 0); streamExtLength.Write(bytesExtLength, 0, bytesExtLength.Length); result = System.Text.Encoding.Default.GetString(streamExtLength.ToArray()); int ExtLength = Convert.ToInt32(result); streamExtLength.Close(); MemoryStream streamProtocol = new MemoryStream(); Byte[] bytesProtocol = new Byte[4]; clientSocket.Receive(bytesProtocol, bytesProtocol.Length, 0); streamProtocol.Write(bytesProtocol, 0, bytesProtocol.Length); result = System.Text.Encoding.Default.GetString(streamProtocol.ToArray()); string Protocol = result; streamProtocol.Close(); MemoryStream streamExtInfo = new MemoryStream(); Byte[] bytesExtInfo = new Byte[ExtLength]; clientSocket.Receive(bytesExtInfo, bytesExtInfo.Length, 0); streamExtInfo.Write(bytesExtInfo, 0, bytesExtInfo.Length); result = System.Text.Encoding.Default.GetString(streamExtInfo.ToArray()); byte[] Buffer = Convert.FromBase64String(result); string strExtInfo = UTF8Encoding.UTF8.GetString(Buffer); streamExtInfo.Close(); MODEL.FileTrackQuery ExtInfo = new MODEL.FileTrackQuery(); ExtInfo = JsonConvert.DeserializeObject<MODEL.FileTrackQuery>(strExtInfo); if (ExtInfo.code == "00") { FileInfo fi = new FileInfo(FileName); DirectoryInfo di = fi.Directory; if (!di.Exists) { di.Create(); } FileStream streamPacketInfo = new FileStream(FileName, FileMode.Create); if (PacketLength > 0) { Byte[] bytesPacketInfo = new Byte[PacketLength]; int bytes = 0; do { bytes = clientSocket.Receive(bytesPacketInfo, bytesPacketInfo.Length, 0); streamPacketInfo.Write(bytesPacketInfo, 0, bytes); } while (bytes > 0); } streamPacketInfo.Close(); } clientSocket.Close(); string strLogFile = System.AppDomain.CurrentDomain.BaseDirectory + "debug.txt"; StreamWriter sw = new StreamWriter(strLogFile, true); sw.WriteLine("PacketLength : " + PacketLength.ToString()); sw.WriteLine("ExtLength : " + ExtLength.ToString()); sw.WriteLine("strExtInfo : " + strExtInfo); sw.WriteLine("ExtInfo.code : " + ExtInfo.code); sw.WriteLine("\n------------------------------------------------------------------------\n"); sw.Flush(); sw.Close(); } catch (Exception e) { string strError = ""; DAL.Common.WriteErrorLog(e, strError); } return result; } public string GetSocketFile(string strSend, string FileName) { string strDatas = ""; string strResult = ""; string strExtLength = ""; try { //Socket连接 SocketConnect(); //发送信息 SocketSend(strSend); //接收服务器的信息 strResult = SocketReceiveFile(FileName); //获取扩展信息的长度 //strExtLength = strResult.Substring(16, 12); //int ExtLength = Convert.ToInt32(strExtLength); //扩展信息,暂不使用 //string strExtInfo = strResult.Substring(32, ExtLength); //获取包体的内容 //strDatas = strResult.Substring(ExtLength + 32); } catch (Exception e) { string strError = ""; strError += "\r\n strResult = " + strResult; strError += "\r\n strExtLength = " + strExtLength; DAL.Common.WriteErrorLog(e, strError); strDatas = ""; } return strDatas; } public byte[] bytesReceived { get; set; } } } MODEL完整代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MODEL { public enum ClientEditionEnum { Enterprise,//企业版 Personal,//个人版 Internal,//内部版 None,//error } /// <summary> /// 授权文件内容 /// </summary> public class AuthorizeFileInfo { public string startTime { get; set; } public string expiryTime { get; set; } public string licenseID { get; set; } public string licensePassword { get; set; } public string terminalID { get; set; } public string customName { get; set; } public string customID { get; set; } public AuthorizeFileInfo() { startTime = ""; expiryTime = ""; licenseID = ""; licensePassword = ""; terminalID = ""; customName = ""; customID = ""; } } /// <summary> /// 通用返回值 /// </summary> /// public class CommonResult { public string code { get; set; } public string message { get; set; } public CommonResult() { code = ""; message = ""; } } public class EnterpriseConfirmAuthorizeDatas { public string sessionID { get; set; } public EnterpriseConfirmAuthorizeDatas() { sessionID = ""; } } /// <summary> /// 企业版授权校验接口 /// </summary> public class EnterpriseConfirmAuthorizeResult { public string code { get; set; } public string message { get; set; } public EnterpriseConfirmAuthorizeDatas datas { get; set; } public EnterpriseConfirmAuthorizeResult() { code = ""; message = ""; datas = new EnterpriseConfirmAuthorizeDatas(); } } public class PersonalConfirmAuthorizeDatas { public string sessionID { get; set; } public string licenseInfo { get; set; } public PersonalConfirmAuthorizeDatas() { sessionID = ""; licenseInfo = ""; } } /// <summary> /// 个人版授权校验接口 /// </summary> public class PersonalConfirmAuthorizeResult { public string code { get; set; } public string message { get; set; } public PersonalConfirmAuthorizeDatas datas { get; set; } public PersonalConfirmAuthorizeResult() { code = ""; message = ""; datas = new PersonalConfirmAuthorizeDatas(); } } /// <summary> /// 鉴权信息,每次调用安全接口时使用 /// </summary> public class LicInfo { public string licenseID { get; set; } public string licensePassword { get; set; } public string terminalID { get; set; } public string deviceID { get; set; } public string sessionID { get; set; } public LicInfo() { licenseID = ""; licensePassword = ""; terminalID = ""; deviceID = ""; sessionID = ""; } } /// <summary> /// java引擎的参数 /// </summary> public class JavaEngineArg { public string licenseID { get; set; } public string licensePassword { get; set; } public string terminalID { get; set; } public string customName { get; set; } public string customID { get; set; } public string deviceID { get; set; } public JavaEngineArg() { licenseID = ""; licensePassword = ""; terminalID = ""; customName = ""; customID = ""; deviceID = ""; } } /// <summary> /// 用户登录接口(一),非安全接口 /// </summary> /// public class UserInfoUnSafe { public string userID { get; set; } public string userName { get; set; } public string departmentName { get; set; } public UserInfoUnSafe() { userID = ""; userName = ""; departmentName = ""; } } public class UserLoginUnSafe { public string code { get; set; } public string message { get; set; } public UserInfoUnSafe datas { get; set; } public UserLoginUnSafe() { code = ""; message = ""; datas = new UserInfoUnSafe(); } } /// <summary> /// 个人版用户登录接口,非安全接口 /// </summary> /// public class UserInfoForPersonal { public string userID { get; set; } public string userName { get; set; } public string departmentName { get; set; } public string licenseInfo { get; set; } public UserInfoForPersonal() { userID = ""; userName = ""; departmentName = ""; licenseInfo = ""; } } public class UserLoginForPersonal { public string code { get; set; } public string message { get; set; } public UserInfoForPersonal datas { get; set; } public UserLoginForPersonal() { code = ""; message = ""; datas = new UserInfoForPersonal(); } } /// <summary> /// 用户登录接口(二),安全接口 /// </summary> /// public class UserInfoSafe { public string userSessionID { get; set; } public string userID { get; set; } public string userName { get; set; } public string departmentName { get; set; } public string activeTime { get; set; } public UserInfoSafe() { userSessionID = ""; userID = ""; userName = ""; departmentName = ""; activeTime = ""; } } public class UserLoginSafe { public string code { get; set; } public string message { get; set; } public UserInfoSafe datas { get; set; } public UserLoginSafe() { code = ""; message = ""; datas = new UserInfoSafe(); } } /// <summary> /// 更新检查接口 /// </summary> /// public class SingleVersion { public string softID { get; set; } public int version { get; set; } public SingleVersion() { softID = ""; version = new int(); } } public class Versions { public List<SingleVersion> versions { get; set; } public Versions() { versions = new List<SingleVersion>(); } } public class VersionUpdate { public string softID { get; set; } public int version { get; set; } public string url { get; set; } public VersionUpdate() { softID = ""; version = new int(); url = ""; } } public class VersionCheck { public string code { get; set; } public string message { get; set; } public List<VersionUpdate> datas { get; set; } public VersionCheck() { code = ""; message = ""; datas = new List<VersionUpdate>(); } } /// <summary> /// 数据源信息查询接口 /// </summary> /// public class OptInfoQuery { public string createUserID { get; set; } public string createUserName { get; set; } public string createUserTime { get; set; } public OptInfoQuery() { createUserID = ""; createUserName = ""; createUserTime = ""; } } public class Period { public int cycle { get; set; } public int cycleUnit { get; set; } public string timer { get; set; } public Period() { cycle = 1; cycleUnit = 1; timer = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); } } public class StrategyConfig { public int backType { get; set; } public int taskType { get; set; } public Period config { get; set; } public StrategyConfig() { backType = 0; taskType = 1; config = new Period(); } } public class FilterFileSuffix { public string suffix { get; set; } public FilterFileSuffix() { suffix = ""; } } public class Scan { public int scanType { get; set; } public string root { get; set; } public bool scanHideFile { get; set; } public string verifyCompleteName { get; set; } public int verifyCompleteMaxCount { get; set; } public int verifyCompleteTimer { get; set; } public string fileAttrGainer { get; set; } public bool recordCanNotReadFileInfo { get; set; } public bool recordEmptyDirectory { get; set; } public bool recordEmptyFile { get; set; } public List<FilterFileSuffix> filterFileSuffix { get; set; } public Scan() { scanType = 2; root = ""; scanHideFile = false; verifyCompleteName = ""; verifyCompleteMaxCount = 5; verifyCompleteTimer = 10000; fileAttrGainer = "null"; recordCanNotReadFileInfo = false; recordEmptyDirectory = false; recordEmptyFile = false; filterFileSuffix = new List<FilterFileSuffix>(); } } public class DataSourceConfigQuery { public int status { get; set; } public int dataSourceType { get; set; } public string dataSourceID { get; set; } public string dataSourceName { get; set; } public string dataSourceDescription { get; set; } public Scan config { get; set; } public DataSourceConfigQuery() { status = 0; dataSourceType = 0; dataSourceID = ""; dataSourceName = ""; dataSourceDescription = ""; config = new Scan(); } } public class DatasQuery { public OptInfoQuery optInfo { get; set; } public StrategyConfig strategyConfig { get; set; } public DataSourceConfigQuery dataSourceConfig { get; set; } public DatasQuery() { optInfo = new OptInfoQuery(); strategyConfig = new StrategyConfig(); dataSourceConfig = new DataSourceConfigQuery(); } } public class DataSourceInfoQuery { public string code { get; set; } public string message { get; set; } public List<DatasQuery> datas { get; set; } public DataSourceInfoQuery() { code = ""; message = ""; datas = new List<DatasQuery>(); } } public class WebSite { public string ExpirationTime { get; set; } public string WebSiteSpace { get; set; } public bool DataBaseEnable { get; set; } public string DataBaseUserName { get; set; } public string DataBasePassword { get; set; } public string DataBaseMark { get; set; } public string WebSiteAdmin { get; set; } public string WebSitePassword { get; set; } public WebSite() { ExpirationTime = ""; WebSiteSpace = ""; DataBaseEnable = false; DataBaseUserName = ""; DataBasePassword = ""; DataBaseMark = ""; WebSiteAdmin = ""; WebSitePassword = ""; } } public class WebSiteDatasQuery { public OptInfoQuery optInfo { get; set; } public StrategyConfig strategyConfig { get; set; } public DataSourceConfigQuery dataSourceConfig { get; set; } public WebSite webSiteConfig { get; set; } public WebSiteDatasQuery() { optInfo = new OptInfoQuery(); strategyConfig = new StrategyConfig(); dataSourceConfig = new DataSourceConfigQuery(); webSiteConfig = new WebSite(); } } public class WebSiteDataSourceInfoQuery { public string code { get; set; } public string message { get; set; } public List<WebSiteDatasQuery> datas { get; set; } public WebSiteDataSourceInfoQuery() { code = ""; message = ""; datas = new List<WebSiteDatasQuery>(); } } /// <summary> /// 新增数据源接口 /// </summary> /// public class OptInfoNew { public bool forceFlag { get; set; } public OptInfoNew() { forceFlag = true; } } public class DataSourceConfigNew { public int dataSourceType { get; set; } public string dataSourceName { get; set; } public string dataSourceDescription { get; set; } public Scan config { get; set; } public DataSourceConfigNew() { dataSourceType = 0; dataSourceName = ""; dataSourceDescription = ""; config = new Scan(); } } public class DataSourceNew { public OptInfoNew optInfo { get; set; } public StrategyConfig strategyConfig { get; set; } public DataSourceConfigNew dataSourceConfig { get; set; } public DataSourceNew() { optInfo = new OptInfoNew(); strategyConfig = new StrategyConfig(); dataSourceConfig = new DataSourceConfigNew(); } } /// <summary> /// 修改数据源接口 /// </summary> /// public class DataSourceModify { public StrategyConfig strategyConfig { get; set; } public DataSourceConfigQuery dataSourceConfig { get; set; } public DataSourceModify() { strategyConfig = new StrategyConfig(); dataSourceConfig = new DataSourceConfigQuery(); } } /// <summary> /// 停用/启用数据源接口 /// </summary> /// public class DataSourceStatus { public string dataSourceID { get; set; } public int optType { get; set; } public DataSourceStatus() { dataSourceID = ""; optType = new int(); } } /// <summary> /// 数据源数据,仅用于存放数据 /// </summary> /// public class DataSourceData { public List<DatasQuery> datas { get; set; } public DataSourceData() { datas = new List<DatasQuery>(); } } /// <summary> /// WebSite数据源数据,仅用于存放数据 /// </summary> /// public class WebSiteDataSourceData { public List<WebSiteDatasQuery> datas { get; set; } public WebSiteDataSourceData() { datas = new List<WebSiteDatasQuery>(); } } /// <summary> /// 文件恢复,版本查询 /// </summary> /// public class DataSourceVersionArg { // 通讯令牌 public string secretKey { get; set; }//由token进过MD5->BASE64->MD5获得 // 任务令牌 public string token { get; set; }//客户端生成一个UUID // 前置机编号 public string terminalId { get; set; } // 操作用户编号 public string optUserID { get; set; } public DataSourceVersionArg() { secretKey = ""; token = ""; terminalId = ""; optUserID = ""; } } public class FileVersions { public int file_count { get; set; } public long space_size { get; set; } public string task_id { get; set; } public string task_time { get; set; } public int total_count { get; set; } public string version { get; set; } public FileVersions() { file_count = new int(); space_size = new long(); task_id = ""; task_time = ""; total_count = new int(); version = ""; } } public class DataSourceVersion { public Scan datasourceConfig { get; set; } public string datasourceId { get; set; } public string datasourceName { get; set; } public int datasourceStatus { get; set; } public int datasourceType { get; set; } public List<FileVersions> versions { get; set; } public DataSourceVersion() { datasourceConfig = new Scan(); datasourceId = ""; datasourceName = ""; datasourceStatus = new int(); datasourceType = new int(); versions = new List<FileVersions>(); } } /// <summary> /// 查询数据源接口 /// </summary> public class DataSourceVersionQuery { public string code { get; set; } public string message { get; set; } public List<DataSourceVersion> datas { get; set; } public DataSourceVersionQuery() { code = ""; message = ""; datas = new List<DataSourceVersion>(); } } /// <summary> /// 数据源版本信息 /// </summary> public class DataSourceVersionDatas { public List<DataSourceVersion> datas { get; set; } public DataSourceVersionDatas() { datas = new List<DataSourceVersion>(); } } /// <summary> /// 文件恢复,文件信息查询 /// </summary> /// public class QueryFileInfoArg { // 通讯令牌 public string secretKey { get; set; }//由token进过MD5->BASE64->MD5获得 // 任务令牌 public string token { get; set; }//客户端生成一个UUID // 数据源编号 public string datasourceId { get; set; } // 操作用户编号 public string optUserID { get; set; } // 目录文件编号--如果为根目录使用 DS_ROOT public string fileID { get; set; } // 查询的版本编号 如果是综合分析 这个字段设置为 ALL public string taskID { get; set; } public QueryFileInfoArg() { secretKey = ""; token = ""; datasourceId = ""; optUserID = ""; fileID = ""; taskID = ""; } } public class FileInfoCondition { public string datasourceId { get; set; } public string parentId { get; set; } public string taskID { get; set; } public FileInfoCondition() { datasourceId = ""; parentId = ""; taskID = ""; } } public class FileInfo { // 文件唯一编号 public string file_id { get; set; } // 源相对目录 public string file_src_path { get; set; } // 文件名 public string file_name { get; set; } // 文件后缀 public string file_suffix { get; set; } // 是否为文件 public bool is_file { get; set; } // 上级文件编号 public string parent_id { get; set; } // 是否删除 public bool is_del { get; set; } // 是否隐藏 public bool is_hide { get; set; } // 文件大小 public int size { get; set; } // 文件创建时间 public string create_time { get; set; } // 文件创建人 public string create_user { get; set; } // 文件最后修改时间 public string lm_time { get; set; } // 文件最后修改人 public string lm_user { get; set; } // 是否可读 public bool can_read { get; set; } public FileInfo() { file_id = ""; file_src_path = ""; file_name = ""; file_suffix = ""; is_file = new bool(); parent_id = ""; is_del = new bool(); is_hide = new bool(); size = new int(); create_time = ""; create_user = ""; lm_time = ""; lm_user = ""; can_read = new bool(); } } public class FileInfoAndCondition { public FileInfoCondition condition { get; set; } public List<FileInfo> fileInfos { get; set; } public FileInfoAndCondition() { condition = new FileInfoCondition(); fileInfos = new List<FileInfo>(); } } /// <summary> /// 查询文件信息接口 /// </summary> public class FileInfoQuery { public string code { get; set; } public string message { get; set; } public FileInfoAndCondition datas { get; set; } public FileInfoQuery() { code = ""; message = ""; datas = new FileInfoAndCondition(); } } /// <summary> /// 文件信息 /// </summary> public class FileInfoData { public List<FileInfo> datas { get; set; } public FileInfoData() { datas = new List<FileInfo>(); } } public class QueryFileTrackArg { // 通讯令牌 public string secretKey { get; set; }//由token进过MD5->BASE64->MD5获得 // 任务令牌 public string token { get; set; }//客户端生成一个UUID // 文件编号 public string fileID { get; set; } // 操作用户编号 public string optUserID { get; set; } // 查询的版本编号 public string taskID { get; set; } public QueryFileTrackArg() { secretKey = ""; token = ""; fileID = ""; optUserID = ""; taskID = ""; } } public class FileTrack { // 文件操作 public string act_cmd { get; set; } // 是否可读 public bool can_read { get; set; } // 文件创建时间 public string create_time { get; set; } // 文件创建人 public string create_user { get; set; } // 是否删除 public bool is_del { get; set; } // 是否隐藏 public bool is_hide { get; set; } // 文件最后修改时间 public string lm_time { get; set; } // 文件最后修改人 public string lm_user { get; set; } // 文件大小 public int size { get; set; } public string taskID { get; set; } public FileTrack() { act_cmd = ""; can_read = new bool(); create_time = ""; create_user = ""; is_del = new bool(); is_hide = new bool(); lm_time = ""; lm_user = ""; size = new int(); taskID = ""; } } public class FileTrackCondition { public string fileID { get; set; } public string taskID { get; set; } public FileTrackCondition() { fileID = ""; taskID = ""; } } /// <summary> /// 查询文件轨迹接口 /// </summary> public class FileTrackQuery { public string code { get; set; } public string message { get; set; } public FileTrackCondition condition { get; set; } public List<FileTrack> datas { get; set; } public FileTrackQuery() { code = ""; message = ""; condition = new FileTrackCondition(); datas = new List<FileTrack>(); } } /// <summary> /// 文件轨迹 /// </summary> public class FileTrackData { public List<FileTrack> datas { get; set; } public FileTrackData() { datas = new List<FileTrack>(); } } /// <summary> /// 字典item /// </summary> public class DictionaryData { public string version { get; set; } public string task_time { get; set; } public DictionaryData() { version = ""; task_time = ""; } } public class FileRecoverArg { // 通讯令牌 public string secretKey { get; set; }//由token进过MD5->BASE64->MD5获得 // 任务令牌 public string token { get; set; }//客户端生成一个UUID // 操作用户编号 public string optUserID { get; set; } public string fileID { get; set; } public string taskID { get; set; } public string password { get; set; } public FileRecoverArg() { secretKey = ""; token = ""; optUserID = ""; fileID = ""; taskID = ""; password = ""; } } }

DataTable.Rows.Add(item)抛出错误:“值不能为 null。参数名: key”

界面功能是选则一个功能范围,然后点击新增,在界面列表中新增一行数据。 错误出现场景:选择同一个功能范围,点击新增后,代码会执行DataTable.Rows.Add(item)这句,大约有20%的概率出现如题错误。具体错误信息如下: 捕捉到 System.ArgumentNullException _HResult=-2147467261 _message=值不能为 null。 HResult=-2147467261 IsTransient=false Message=值不能为 null。 参数名: key Source=mscorlib ParamName=key StackTrace: 在 System.Collections.Generic.Dictionary`2.FindEntry(TKey key) 在 System.Collections.Generic.Dictionary`2.get_Item(TKey key) 在 System.Data.DataView.MaintainDataView(ListChangedType changedType, DataRow row, Boolean trackAddRemove) 在 System.Data.DataViewListener.MaintainDataView(ListChangedType changedType, DataRow row, Boolean trackAddRemove) 在 System.Data.Index.<>c__DisplayClass5.<MaintainDataView>b__4(DataViewListener listener, ListChangedType type, DataRow row, Boolean track) 在 System.Data.Listeners`1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action`4 action) 在 System.Data.Index.MaintainDataView(ListChangedType changedType, Int32 record, Boolean trackAddRemove) 在 System.Data.Index.InsertRecord(Int32 record, Boolean fireEvent) 在 System.Data.Index.ApplyChangeAction(Int32 record, Int32 action, Int32 changeRecord) 在 System.Data.Index.RecordStateChanged(Int32 record, DataViewRowState oldState, DataViewRowState newState) 在 System.Data.DataTable.RecordStateChanged(Int32 record1, DataViewRowState oldState1, DataViewRowState newState1, Int32 record2, DataViewRowState oldState2, DataViewRowState newState2) 在 System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean suppressEnsurePropertyChanged, Int32 position, Boolean fireEvent, Exception& deferredException) 在 System.Data.DataTable.InsertRow(DataRow row, Int64 proposedID, Int32 pos, Boolean fireEvent) 在 System.Data.DataRowCollection.Add(DataRow row) InnerException: 跟踪代码结果: item是datatable.row类型。 (不知道怎么放图片)在正常与错误情况下,item.ItemArray有内容,部分为空字符串,内容除时间不一样之外,其余均相同。正常时正常添加,错误时,执行到add方法报错,捕捉错误后,item.ItemArray中的值都变成空,类型为System.DBNull.

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

立方体线框模型透视投影 (计算机图形学实验)

计算机图形学实验 立方体线框模型透视投影 的可执行文件,亲测可运行,若需报告可以联系我,期待和各位交流

2019 AI开发者大会

2019 AI开发者大会

组成原理课程设计(实现机器数的真值还原等功能)

实现机器数的真值还原(定点小数)、定点小数的单符号位补码加减运算、定点小数的补码乘法运算和浮点数的加减运算。

C/C++跨平台研发从基础到高阶实战系列套餐

一 专题从基础的C语言核心到c++ 和stl完成基础强化; 二 再到数据结构,设计模式完成专业计算机技能强化; 三 通过跨平台网络编程,linux编程,qt界面编程,mfc编程,windows编程,c++与lua联合编程来完成应用强化 四 最后通过基于ffmpeg的音视频播放器,直播推流,屏幕录像,

MFC一站式终极全套课程包

该套餐共包含从C小白到C++到MFC的全部课程,整套学下来绝对成为一名C++大牛!!!

软件测试2小时入门

软件测试2小时入门

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

计算机图形学-球的光照模型课程设计

计算机图形学-球的光照模型,有代码完美运行,有课程设计书

Linux常用命令大全(非常全!!!)

Linux常用命令大全(非常全!!!) 最近都在和Linux打交道,感觉还不错。我觉得Linux相比windows比较麻烦的就是很多东西都要用命令来控制,当然,这也是很多人喜欢linux的原因,比较短小但却功能强大。我将我了解到的命令列举一下,仅供大家参考: 系统信息 arch 显示机器的处理器架构 uname -m 显示机器的处理器架构 uname -r 显示正在使用的内核版本 d...

因为看了这些书,我大二就拿了华为Offer

四年了,四年,你知道大学这四年我怎么过的么?

深度学习原理+项目实战+算法详解+主流框架(套餐)

深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

fakeLocation13.5.1.zip

fakeLocation13.5.1 虚拟定位 ios13.5.1的最新驱动下载,iPhone/iPad免越狱虚拟定位工具Location-cleaned驱动已更新

UnityLicence

UnityLicence

Python可以这样学(第一季:Python内功修炼)

Python可以这样学(第一季:Python内功修炼)

Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

土豆浏览器

土豆浏览器可以用来看各种搞笑、电影、电视剧视频

【数据结构与算法综合实验】欢乐连连看(C++ & MFC)案例

这是武汉理工大学计算机学院数据结构与算法综合实验课程的第三次项目:欢乐连连看(C++ & MFC)迭代开发代码。运行环境:VS2017。已经实现功能:开始游戏、消子、判断胜负、提示、重排、计时、帮助。

php+mysql学生成绩管理系统

学生成绩管理系统,分三个模块:学生,教师和管理员。 管理员模块:负责学生、老师信息的增删改;发布课程信息的增删改,以便让学生选课;审核老师提交的学生成绩并且打印成绩存档;按照课号查询每个课号的学生成绩

多功能数字钟.zip

利用数字电子计数知识设计并制作的数字电子钟(含multisim仿真),该数字钟具有显示星期、24小时制时间、闹铃、整点报时、时间校准功能

推荐24个国外黄色网站欣赏

在中国清朝,明黄色的衣服只有皇子才有资格穿,慢慢的黄色在中国就成了高贵的颜色。在人们的色彩印象中,黄色也表现为暂停。所以当你的网页设计采用黄色的时候,会让人们在你的网页前停留。 黄色,就像橙色和红色,黄色也是一个暖色。它有大自然、阳光、春天的涵义,而且通常被认为是一个快乐和有希望的色彩。黄色是所有色相中最能发光的颜色,给人轻快,透明,辉煌,充满希望的色彩印象。 黄色是一个高可见的色...

u-boot-2015.07.tar.bz2

uboot-2015-07最新代码,喜欢的朋友请拿去

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

学生成绩管理系统(PHP + MYSQL)

做的是数据库课程设计,使用的php + MySQL,本来是黄金搭配也就没啥说的,推荐使用wamp服务器,里面有详细的使用说明,带有界面的啊!呵呵 不行的话,可以给我留言!

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

C++语言基础视频教程

C++语言基础视频教程

玩转Python-Python3基础入门

玩转Python-Python3基础入门

相关热词 c# 解析cad c#数字格式化万 c#int转byte c#格式化日期 c# wpf 表格 c# 实现ad域验证登录 c#心跳包机制 c#使用fmod.dll c#dll vb 调用 c# outlook
立即提问
相关内容推荐