Home > OS >  TypeInitializationException on one computer, but not another
TypeInitializationException on one computer, but not another

Time:12-19

I have just installed Visual Studio on a new computer and loaded an existing project.

On running I am getting a TypeInitializationException "Conversion from string to type 'Integer' is not valid.

The variable has been globally defined as a string variable so should not be expecting an integer.

The project is running fine on the original computer. Both have the same version of VS.

Hope someone can help.

CodePudding user response:

I worked it out.

My global variables are defined in a module.

One global variable was defined as:

Public lag As Integer = GetSetting(AppName, "Settings", "Lag")

Because the registry setting didn't exist it threw an exeption, and as a result, no variables in the module were being initialized.

  •  Tags:  
  • .net
  • Related