After installing .NET 4.0, I am now getting an exception on this statement:
if (mainForm.versionNumber.Contains("BETA"))
This is how versionNumber is defined:
public static string versionNumber = "1.1.1 " + compileDate.ToString("dd-MMM-yyyy");
and the run-time errorr is “TypeInitializationException”. What changed from .NET v3.5 to 4.0 that would cause this? And how do I fix it?
UPDATE: here is the exception detail:
> System.TypeInitializationException was unhandled Message=The type
> initializer for 'Media_Inventory_Manager.mainForm' threw an exception.
> Source=PragerMediaInventoryManager
> TypeName=Media_Inventory_Manager.mainForm StackTrace:
> at Media_Inventory_Manager.Prager.Main() in D:\Prager Software\Media Inventory Manager\Program.cs:line 36
> at System.AppDomain._nExecuteAssembly(Assembly 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.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
> at System.Threading.ThreadHelper.ThreadStart() InnerException: System.FormatException
> Message=The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.
> Source=mscorlib
> StackTrace:
> at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
> at System.DateTime.Parse(String s, IFormatProvider provider)
> at Media_Inventory_Manager.mainForm..cctor() in D:\Prager Software\Media Inventory Manager\Main Form.cs:line 38
> InnerException:
I think it is something wrong with a class initializer fails to initialize a type. It really hard to see what happens when you are not show that much code. If you read on mdsn it says:
Reference here
So knowing that i would look at the
InnerExceptionand see whats going on.EDIT
With out knowing more about your code. This could be a way to get the
InnerException