类型初始化器异常 [英] type initializer exception

查看:139
本文介绍了类型初始化器异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我制作了一个在我的系统的本地主机上运行良好的Web应用程序,但是当我将其上传到vps n并试图运行它时,它抛出了一个异常,即类型初始值设定项异常".由于我在app_code文件夹中使用了他汀类的类名而引发了异常.

解决方案

将try..Catch块添加到目标类的构造函数,即来自app_code foler的类.将异常记录到某个.txt文件中,然后查看真正的根本原因是什么.

一种可能是,如果构造函数具有一些引发异常的代码语句,则您将获得此异常.检查是否对VPS系统有任何依赖性,例如配置设置或第三方资源等.

有关详细信息,您可以发布您班级的代码.


感谢Hemant,我已经在try catch块中添加了构造函数,但是控件没有进入构造函数主体并引发异常.


Hi,
I made a web application which is going fine on local host of my system but when i uploaded it on vps n tried to run it its throwing an exception that is "the type initializer exception ". the exception has trowed because of class name which i have taken statin in app_code folder.
Please somebody help me for resolve that problem.

解决方案

Add try..Catch block to constructor of target class i.e. the class from app_code foler. Log the exception to some .txt file and see what is actual root cause.

one possibility is if the constructor has some code statement(s) throwing exception you will get this exception. check for any dependency on VPS system for example Config settings or third party resources etc.

For details you can post code of the your class. specially the constructor.


Thanks Hemant, I already put try catch block with constructor but but control is not entering in constructor body and throwing the exception.


这篇关于类型初始化器异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆