D
Dmitry Bond.
Hi All.
I faced with strange behavior of C# compiler - in some cases it generates
not working code!
I mean code that lead to the exception - System.InvalidProgramException:
Common Language Runtime detected an invalid program.
The situation is following - 3rd vendor library generates a class that
contains too big InitializeComponent method (copy-paste of
InitializeComponent method to empty text file gives us 23.100 lines and size
= 1.9mb). When calls this method is called application immediately crashed
with the message - "System.InvalidProgramException: Common Language Runtime
detected an invalid program."
Content of InitializeComponent is similar to such methods in Windows.Forms
or Asp.Net application - there are initializations of components properties
ans so on - nothing special, just lot of assignments; no local variables -
ony class members used.
Just by a guess I tried to split up that method to more small pieces of
code - InitializeComponent1, InitializeComponent2 and so on. After that
mentioned error disappeared - all things begin to work fine.
I tested this case on 3 different computers - this error is stable (btw, I
my computer is Pentium4-3GHz/1Gb RAM/120Gb HDD, then I do not think that
error could appears because of weak computer).
One more case I tested - Debug and Release builds of that application -
mentioned error appears constantly only in Debug build, Release build of the
application works fine.
And one more interesting thing - this error stable appears in VS.Net 2003
and VS.Net 2005 Beta2.
Then is could be a problem of new VS.Net too.
My questions are:
Is it a BUG in C# compiler? Is it limitation of compiler? Where such
limitations described?
Should I think my conclusion about reason of this error (I mean - too many
code in one class method) is correct?
Or perhaps you could see any other possible reasons of the problem? Which?
Could we expect Microsoft to release the patch in the nearest future?
Or should we ask 3rd vendor to implement the workaround I found (I mean -
splitting up big method to smaller)?
The problem is very serious for us, please help!
WBR,
Dmitry.
I faced with strange behavior of C# compiler - in some cases it generates
not working code!
I mean code that lead to the exception - System.InvalidProgramException:
Common Language Runtime detected an invalid program.
The situation is following - 3rd vendor library generates a class that
contains too big InitializeComponent method (copy-paste of
InitializeComponent method to empty text file gives us 23.100 lines and size
= 1.9mb). When calls this method is called application immediately crashed
with the message - "System.InvalidProgramException: Common Language Runtime
detected an invalid program."
Content of InitializeComponent is similar to such methods in Windows.Forms
or Asp.Net application - there are initializations of components properties
ans so on - nothing special, just lot of assignments; no local variables -
ony class members used.
Just by a guess I tried to split up that method to more small pieces of
code - InitializeComponent1, InitializeComponent2 and so on. After that
mentioned error disappeared - all things begin to work fine.
I tested this case on 3 different computers - this error is stable (btw, I
my computer is Pentium4-3GHz/1Gb RAM/120Gb HDD, then I do not think that
error could appears because of weak computer).
One more case I tested - Debug and Release builds of that application -
mentioned error appears constantly only in Debug build, Release build of the
application works fine.
And one more interesting thing - this error stable appears in VS.Net 2003
and VS.Net 2005 Beta2.
Then is could be a problem of new VS.Net too.
My questions are:
Is it a BUG in C# compiler? Is it limitation of compiler? Where such
limitations described?
Should I think my conclusion about reason of this error (I mean - too many
code in one class method) is correct?
Or perhaps you could see any other possible reasons of the problem? Which?
Could we expect Microsoft to release the patch in the nearest future?
Or should we ask 3rd vendor to implement the workaround I found (I mean -
splitting up big method to smaller)?
The problem is very serious for us, please help!
WBR,
Dmitry.