Questions tagged «invalidoperationexception»

7
可为空的对象必须具有一个值
异常描述中存在悖论:可空对象必须具有值(?!) 这就是问题: 我有一DateTimeExtended堂课 { DateTime? MyDataTime; int? otherdata; } 和一个构造函数 DateTimeExtended(DateTimeExtended myNewDT) { this.MyDateTime = myNewDT.MyDateTime.Value; this.otherdata = myNewDT.otherdata; } 运行此代码 DateTimeExtended res = new DateTimeExtended(oldDTE); 抛出一条InvalidOperationException消息: 可为空的对象必须具有一个值。 myNewDT.MyDateTime.Value-有效并且包含常规DateTime对象。 此消息是什么意思,我在做什么错? 注意oldDTE不是null。我从中删除了Value,myNewDT.MyDateTime但由于生成了setter而引发了相同的异常。

26
ASP.NET MVC:没有为此对象定义无参数构造函数
Server Error in '/' Application. -------------------------------------------------------------------------------- No parameterless constructor defined for this object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.MissingMethodException: No parameterless constructor …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.