0
Answer

CLR Restrictions

Ask a question
Srin Dev

Srin Dev

18y
2.6k
1
I'm generating a cs file at runtime and compiling it using CSharpCompiler. Since I've not really worked on optimizing the algorithm, in some cases my methods inside the file exceed 10,000 lines of code. Since this is generated code not meant for human consumption, I'm not worried about size. But when I execute the generated assembly, it runs till it gets to the rouge method call and I get an exception that CLR found an invalid program. This happens when the method size is too large so I'm guessing that CLR has some restrictions. So my question is why is this a run-time exception and why is the CSharpCompiler class not catching this issue? Also is there some place I can check the specs on maximum sizes of classes, methods, variable names etc. so I can check for them in my generated code?

Next Recommended Forum