gpt4 book ai didi

c# - System.TypeInitializationException 未处理

转载 作者:行者123 更新时间:2023-11-30 14:40:34 28 4
gpt4 key购买 nike

MS Visual Studio 2005 抛出这条消息是什么意思?

"The type initializer for 'RMDC.clsVariables' threw an exception."

错误日志如下

System.TypeInitializationException was unhandled
Message="The type initializer for 'RMDC.clsVariables' threw an exception."
Source="RMDC"
TypeName="RMDC.clsVariables"
StackTrace:
at RMDC.clsFunctions.getRegistryValue() in D:\Magnus Project\Project Backup\RMDC\RMDC\Class\clsFunctions.cs:line 704
at RMDC.Program.Main() in ..\RMDC\RMDC\Program.cs:line 39
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

有问题的类

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Windows.Forms;
using System.Collections;


namespace RMDC
{
class clsVariables
{
public SqlConnection conn = new SqlConnection();

public SqlDataAdapter sAdapter = new SqlDataAdapter();
public DataSet sDataSet = new DataSet();

public static string sMessageBox = "";
public static string sUsername;
public static string sUserFullname;
public static string sUserLogin;
public static string sUserType;
public static int sUserID;
public static string sServer = "system-10";
public static string sDatabase = "";
public static string sDBUserID = "";
public static string sDBPassword = "";
public static bool sDontShow = false;
public static string sCompanyName;
public static string sContactName;
public static string sCompanyAddress;
public static string sPhoneNumber;
public static string sFaxNumber;
public static string sEmailAddress;
public static string sWebAddress;
public static string sOfficeCd = "01";
public static int sfiscalYrId = 1;
public static string sfiscalYr;
public static DateTime sFiscalStart = DateTime.Today;
public static DateTime sFiscalEnd = DateTime.Today;
public static int sRoleId;

public static byte[] m_barrImg;

public static SqlConnection cnn = new SqlConnection();

public OpenFileDialog openIMG = new OpenFileDialog();

public static NepEngCalanderProvider.NepEngDateClass nepDate = new NepEngCalanderProvider.NepEngDateClass();
public static NumberToWord.InWordsClass NumericWords = new NumberToWord.InWordsClass();


public enum QueryType
{
Insert,
Update,
Delete
}
}
}

最佳答案

好吧,这就是它所说的 - RMDC.clsVariables 的类型初始值设定项(这是一个非常规的名称,顺便说一句)中的某些东西爆炸了。

这可能是一个静态变量初始值设定项:

static int foo = GetInitialValueForFoo();

或静态构造函数:

static clsVariables
{
DoSomething();
}

不管它是什么,它都失败了,导致您的类型无法使用。

如果您在调试器中运行代码,它应该在抛出异常时立即中断,从而更容易弄清楚发生了什么。

关于c# - System.TypeInitializationException 未处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5179156/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com