Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 获得;类型初始化异常";_C#_Asp.net_Unit Testing - Fatal编程技术网

C# 获得;类型初始化异常";

C# 获得;类型初始化异常";,c#,asp.net,unit-testing,C#,Asp.net,Unit Testing,我在下一行收到类型初始化异常 var path = InputOptions.downloadsPath; InputOptions是我编写的一个类。其中包括: public static readonly string parentpath = Directory.GetParent(Directory.GetCurrentDirectory()).ToString(); public static readonly string downloadsPath = parentpath + @

我在下一行收到类型初始化异常

var path = InputOptions.downloadsPath;
InputOptions
是我编写的一个类。其中包括:

public static readonly string parentpath = Directory.GetParent(Directory.GetCurrentDirectory()).ToString();
public static readonly string downloadsPath = parentpath + @"\DATA\Download";

为“path”变量赋值时出错。为什么要重新赋值为只读值?这难道不能阻止它成为只读的吗?你问的问题完全不清楚。特别是你的简约代码对再现你的问题没有多大帮助。它甚至不编译。您能提供一个吗?我已经编辑了问题,我没有重新分配值。现在可以理解吗??