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.ArgumentNullException: Value cannot be null.
Parameter name: mapping
Source Error:
Line 45: #endregion
Line 46:
Line 47: public db() :
Line 48: base(global::data.Properties.Settings.Default.nanocrmConnectionString, mappingSource)
Line 49: {
如果我实现这样的类,这就是我得到的:
partial class db
{
static db _db = new db();
public static db GetInstance()
{
return _db;
}
}
db 是一个 linq2sql 数据上下文
为什么会发生这种情况以及如何解决这个问题?
UPD:该文件由 linq2sql 生成:
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
public db() :
base(global::data.Properties.Settings.Default.nanocrmConnectionString, mappingSource)
{
OnCreated();
}
如果我在方法内实例化 db(不是这里的属性)一切正常。并且静态方法一直工作到今天早上,但现在即使是 2 天前的版本(从存储库恢复)也出现了同样的错误。
更新 2:
所以这是我解决问题后的部分课程:
namespace data
{
using System.Data.Linq.Mapping;
partial class db
{
static db _db = new db(global::data.Properties.Settings.Default.nanocrmConnectionString, new AttributeMappingSource());
public static db GetInstance()
{
return _db;
}
}
}