当程序依赖static xxxx=xxxxx.xxxx 而xxx依赖某个xxxxx dll,或者xxxxx.dll依赖config 当xxxxx.dll缺少依赖dll,或者缺少config配置节,框架会提示无法初始化
[quote=引用 7 楼 奇点码农 的回复:] [quote=引用 3 楼 杀马特丶蛮牛 的回复:] 如下代码,调用test()就会报 “类型初始值设定项引发异常” 了,看看有没有这种情况 public class Test { public static int n = Convert.ToInt32("null"); public static int test() { return 1; } }
public class Test { public static int n = Convert.ToInt32("null"); public static int test() { return 1; } }
[quote=引用 3 楼 杀马特丶蛮牛 的回复:] 如下代码,调用test()就会报 “类型初始值设定项引发异常” 了,看看有没有这种情况 public class Test { public static int n = Convert.ToInt32("null"); public static int test() { return 1; } }
如下代码,调用test()就会报 “类型初始值设定项引发异常” 了,看看有没有这种情况 public class Test { public static int n = Convert.ToInt32("null"); public static int test() { return 1; } }
你dbhelper文件头部有没有类似这样的代码string connstr = ConfigurationManager.AppSettings["connstr"];
把报错的static 那一行贴出来。 一般来说,是 数据库连接字符串问题。
111,094
社区成员
642,554
社区内容
加载中
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧