Unhandled Exception: System.StackOverflowException when using Switch Statement?

There is an issue where the switch statement does not work anymore and then Unity complains that another script is to blame for this exception. I don’t know why or how this error is occurring but it is stopping me from playing the build of the game inside the editor. The full error reads:

Unhandled Exception: System.StackOverflowException: The requested operation caused a stack overflow.

  at Mono.CSharp.ExplicitBlock.EmitMeta (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 

The script that has the switch statement with the error has only this inside:

switch(serialNumber)
{
    case 0: break;
}

While the other script has thousands of cases (too many to put in this question), why is it complaining?

My speculation from what I am getting from this exception is that a switch statement can hold only so many cases, but if that was true, then how many cases can I put in a switch statement?

I am so confused on this, any help would be appreciated.

Update: When I comment out the line “case 0: break;” from the switch statement. I get this message:

Assets/Scripts/Database.cs(122,17): warning CS1522: Empty switch block

Unhandled Exception: System.StackOverflowException: The requested operation caused a stack overflow.

  at Mono.CSharp.ExplicitBlock.EmitMeta (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 

Normally that would be a warning, but it shows it as an error and still prevents me from running the build in the editor.

Well, I think I found the Problem. There is a maximum number of cases you can have in a single switch statement. Any more than the maximum and it will throw this exception. I did some experimenting by taking the switch statement cases out chuck by chunk. Then slowly added the chunks back in (since I did this alphabetically using the strings within each function in each separate case, I did it by letter). Once I reached the offending category letter, I then took the chunk of cases out and only put half in, I repeated the steps until I found the single offending case. But there was nothing different or odd about it (nothing was calling a function recursively).

So I commented the line out and the build works, then un-commented the line and it gives the error again. So to verify that it was not just a fluke, I tested this with a known good case right above it. Commented out that case and un-commented the offending case, and it strangely worked with that case. So I concluded that there might be a maximum of about 5000 case statements for any single given switch statement.

I do appreciate all the help from everyone that suggested to do research and backtracking on this problem. And I should have tried other methods of storing information for items more efficiently (I need to look up array and dictionary searches for this).

(Also if anyone can double check if this is effecting anyone else, then I can make this as an answer, otherwise, if there is an alternative, let me know).