Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello, I have found an issue that I am unable to resolve. Does anyone know a fix for this Type Initialization Exception based on the exception details i've included. Thanks, Jake

System.TypeInitializationException was unhandled
HResult=-2146233036
Message=The type initializer for 'TextEditor.Character' threw an exception.
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:line 38
at TextEditor.TextEditor..ctor() in c:\users\<my name>\documents\visual studio 2010\Projects\TextEditor\TextEditor\TextEditor.cs:line 21
at TextEditor.Program.Main() in c:\users\<my name>\documents\visual studio 2010\Projects\TextEditor\TextEditor\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IndexOutOfRangeException
HResult=-2146233080
Message=Index was outside the bounds of the array.
Source=TextEditor
StackTrace:
at TextEditor.PixelMap.set_Item(Int32 x, Int32 y, Boolean value) in c:\users\<my name>\documents\visual studio 2010\Projects\TextEditor\TextEditor\TextEditor.cs:line 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:line 127
at TextEditor.PixelMap..ctor(Image image) in c:\users\<my name>\documents\visual studio 2010\Projects\TextEditor\TextEditor\TextEditor.cs:line 109
at TextEditor.PixelMap..ctor(String path) in c:\users\<my name>\documents\visual studio 2010\Projects\TextEditor\TextEditor\TextEditor.cs:line 92
at TextEditor.Character.FromImageSimple(Char letter) in c:\users\<my name>\documents\visual studio 2010\Projects\TextEditor\TextEditor\TextEditor.cs:line 220
at TextEditor.Character..cctor() in c:\users\<my name>\documents\visual studio 2010\Projects\TextEditor\TextEditor\TextEditor.cs:line 247
InnerException:
Posted

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;


Without seeing any of the code, that's all we can tell you.
 
Share this answer
 
v2
Comments
mr. ITS all good 16-Jul-14 10:27am    
thanks, i'll look into it
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900