我不知道我是如何得到类型初始化异常的!

我不知道我是如何得到类型初始化异常的!

问题描述:

您好,我发现了一个无法解决的问题。有没有人知道基于我所包含的异常细节的此类型初始化异常的修复程序。谢谢,杰克



System.TypeInitializationException未处理

HResult = -2146233036

Message ='TextEditor.Character'的类型初始值设定项引发异常。

Source = TextEditor

TypeName = TextEditor.Character

StackTrace:

at TextEditor.Character..ctor()

at TextEditor.TextEditor.UpdateBlock(Point position)in c:\users \< my name> \ documents \ visual studio 2010 \Projects\TextEditor\TextEditor\TextEditor.cs:第38行

at TextEditor.TextEditor..ctor()in c:\users \<我的名字> \documents\visual studio 2010 \Projects\TextEditor\TextEditor\TextEditor.cs:第21行

at c:\ userss中的TextEditor.Program.Main() \< my name> \documents\visual studio 2010 \Projects\TextEditor\TextEditor\Program.cs:第18行

在System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,String [] args)

在System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)

at System.Threading.ThreadHelper.ThreadStart_Context(对象状态)中的$。
。在System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext)中的
.Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

,ContextCallback回调,Object state,Boolean preserveSyncCtx)

在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,Object state,Boolean preserveSyncCtx)

在System。 Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)

at System.Threading.ThreadHelper.ThreadStart()

InnerException:System.IndexOutOfRangeException

HResult = -2146233080

消息=索引超出了数组的范围。

Source = TextEditor

StackTrace:

at TextEditor.PixelMap.set_Item( Int32 x,Int32 y,布尔值)在c:\users \< my name> \documents\visual studio 2010 \Projects\TextEditor\TextEditor\TextEditor.cs:第138行>
at TextEditor.PixelMap.Set(Boolean b,Int32 x,Int32 y)in c:\users \< my name> \documents\visual studio 2010 \Projects\TextEditor \ TextEditor\TextEditor.cs:第127行

at C:\users \< my name> \documents\visual studio 2010中的TextEditor.PixelMap..ctor(图片图片) \\ Projects \TextEditor\TextEditor\TextEditor.cs:第109行

at c:\users \< my name> \中的TextEditor.PixelMap..ctor(字符串路径) documents \ visual studio 2010 \Projects\TextEditor\TextEditor \TextEditor.cs:第92行

at c:\users \< my name> \documents\visual studio 2010 \Projects中的TextEditor.Character.FromImageSimple(Char letter) \TextEditor\TextEditor\TextEditor.cs:第220行

at TextEditor.Character..cctor()in c:\users \< my name> \documents\visual studio 2010 \Projects\TextEditor\TextEditor\TextEditor.cs:第247行

InnerException:

查看内部异常的堆栈跟踪:

  • 字符的静态构造函数类调用 FromImageSimple 方法;
  • FromImageSimple 创建一个新的 PixelMap 实例;
  • PixelMap 构造函数调用 Set(bool,int,int),它在同一个类上调用索引器;
  • PixelMap的索引器 cl屁股试图将一个值放入一个索引太大或太小的数组中;
Look at the stack-track of the inner exception:
  • The static constructor of your Character class calls the FromImageSimple method;
  • FromImageSimple creates a new PixelMap instance;
  • The PixelMap constructor calls Set(bool, int, int), which calls the indexer on the same class;
  • The indexer of the PixelMap class is trying to put a value into an array at an index which is either too large or too small;


InnerException:System.IndexOutOfRangeException

消息=索引超出了数组的范围。





TextEditor.cs:第138行



查看列表或数组结构。也许这就是你的问题。
InnerException: System.IndexOutOfRangeException
Message=Index was outside the bounds of the array.


TextEditor.cs:line 138

take a look at list or array-like structures. Perhaps thats your issue.