'System.TypeInitializationException' occurs sometimes only

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Roy Gourgi
    New Member
    • Jul 2011
    • 5

    'System.TypeInitializationException' occurs sometimes only

    Hi,



    I get this error message depending on the parameters that I enter for my constants.

    "An unhandled exception of type 'System.TypeIni tializationExce ption' occurred in TEST_C_26_6_2_C OPY.exe"

    "Additional information: The type initializer for 'aGV' threw an exception."

    The funny thing is that I only get this error message when I enter certain values for my V, K, T, BLOCKS, REPLACEMENT_MAX BLOCK, REPLACEMENT_ACT IVEBLOCKS;

    For example when I enter V = 10, K = 5, T = 3, BLOCKS = 17, REPLACEMENT_MAX BLOCK = 17, REPLACEMENT_ACT IVEBLOCKS = 17

    there are no problems.

    Conversely, when I enter V = 9, K = 4, T = 3, BLOCKS = 25, REPLACEMENT_MAX BLOCK = 25, REPLACEMENT_ACT IVEBLOCKS = 25

    I get the error message pointing to the code in my Main() for the aGV.Cov

    Code:
    for (liMiscLp = 0; liMiscLp <= aGV.BLOCKS; liMiscLp++)
    
    {
    
          aGV.Cov[liMiscLp, liKLp] = liKLp;
    
    }


    These are my constants that I declare in my aGV global variables method:

    Code:
    class aGV
    
    
    
    {
    
    
    
    public const int V = 9; // This is v
    
    public const int K = 4; // This is k
    
    public const int T = 3; // This is t
    
    public const int BLOCKS = 25;
    
    public const int REPLACEMENT_MAXBLOCK = 25;
    
    public const int REPLACEMENT_ACTIVEBLOCKS = 25;
    
    public static int[,] Cov = new int[aGV.BLOCKS + 1, aGV.NOCOLUMNS];
    
    public static int[,] PCov = new int[aGV.BLOCKS + 1, aGV.NOCOLUMNS];
    
    public static int[,] OCov = new int[aGV.BLOCKS + 1, aGV.NOCOLUMNS];
    
    }
    It is as though it is not initializing the array aGV.Cov when I enter different parameters!

    Any ideas why this happens only when certain parameters are entered?



    TIA

    Roy
    Last edited by Rabbit; Apr 10 '13, 05:13 AM. Reason: Please use code tags when posting code.
Working...