TypeInitializationException thrown for Program class

后端 未结 13 819
醉梦人生
醉梦人生 2020-12-10 23:30

My Windows Forms application was working earlier, however suddenly it stopped working. I am getting following exception:

13条回答
  •  执念已碎
    2020-12-11 00:29

    This is one weird issue I had to deal with for the last 2 hours. I solved it by removing the static from the lists I created.

    private static readonly List someList = GlobalConfiguration.Connection.PopulateList();
    

    with this one:

    private readonly List someList = GlobalConfiguration.Connection.PopulateList();
    

    Hope it helps and you don't have to spend two hours to find out the bug...

提交回复
热议问题