Click here to Skip to main content
15,124,780 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting "TypeInitializationException wa unhandled". Please let me know how to eliminate this error

I am getting this erro in second line from below pasted code

Ver = Application.ProductVersion.ToString().Split(".")
Label1.Text = "Version: " & Ver(0) & "." & Ver(1) & "." & Ver(3)
AppVersion = Ver(0) & "." & Ver(1) & "." & Ver(3)

Thank you.

What I have tried:

I tried comment it and run. again same error occur on next line with AppVersion variable
Updated 5-Jan-21 7:14am
Richard MacCutchan 5-Jan-21 11:50am
Check how many fields are actually returned on your call to Split.

1 solution

Your question has only partial code(Declaration part is missing). Always include relevant code in your question.

Based on the error message, check below thread to know about the error & some of situations(It has 3).
TypeInitializationException Class (System) | Microsoft Docs[^]

Few more threads on same error message. Check & fix it by yourself
how to solve System.TypeInitializationException was unhandled exception in - Stack Overflow[^]
c# - TypeInitializationException thrown for Program class - Stack Overflow[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

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