Invalid program exception

L

Longshot

I am new to using C#, and am not able to find any useful help on this
error.

I am running WinXp, with all the patches and updates. I am working under
Visual Studio 2003, and recently I started to recieve this error when I
compile with debugging (F5): an unhandled exception of type
"System.invalidprogramexception" occurred in my.exe

Additional information: Common Runtime Language detected an invalid
program.

Well, if I compile with no debugginh (ctrl + F5) it runs fine with no
errors.

When I step through the code, the error comes up during the call to
InitializeComponent(); which VS created....

I am at a dead end. I have removed code, and the error went away, but not
sure why. I slowly put the code back, only to get it all back with no
error, only to add a few more unrelated controls, and the error pops up
again.

I have not even started to write code yet, this is all just the gui portion
of the project.

Any help or ideas for where to look would be greatly appreciated.

Dave
 
C

codymanix

I am new to using C#, and am not able to find any useful help on this
error.

I am running WinXp, with all the patches and updates. I am working under
Visual Studio 2003, and recently I started to recieve this error when I
compile with debugging (F5): an unhandled exception of type
"System.invalidprogramexception" occurred in my.exe

Additional information: Common Runtime Language detected an invalid
program.

Well, if I compile with no debugginh (ctrl + F5) it runs fine with no
errors.

When I step through the code, the error comes up during the call to
InitializeComponent(); which VS created....

I am at a dead end. I have removed code, and the error went away, but not
sure why. I slowly put the code back, only to get it all back with no
error, only to add a few more unrelated controls, and the error pops up
again.

I have not even started to write code yet, this is all just the gui portion
of the project.


It would be great if you could post your code here that we can see what
might gone wrong.
But this exception could also be caused by a damaged executable file in
visual studio.
 
L

Longshot

It would be great if you could post your code here that we can see
what might gone wrong.
But this exception could also be caused by a damaged executable file
in visual studio.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk

I can post the code, but it is about 4mb uncompressed right now...

I also installed Borlands C# Builder, and get the same error, so I guess
that might narrow it down to the code. 8(

Dave
 
L

Longshot

It would be great if you could post your code here that we can see
what might gone wrong.
But this exception could also be caused by a damaged executable file
in visual studio.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk

I can post the code, but it is about 4mb uncompressed right now...

I also installed Borlands C# Builder, and get the same error, so I guess
that might narrow it down to the code. 8(

Dave
 
L

Longshot

I figured out what the problem is. The InitializeComponent method is too
large.

I removed a large portion of the code from it (at ramdom) created a new
method and pasted it in there, then placed a call to teh method in the cut
codes place, then the project ran just fine when I pressed f5. Ofcourse,
opening designmode hangs the system, but atleast I figured out teh root
problem.

I repeated this test 3 more times, with other random sections of code.
Always works after the removal of the code.

Any ideas on what code if any can be moved out of the InitializeComponent
method to make it smaller?

Or a differant way to do this.

My GUI is for the most part finished, so I really dont need to open it in
designview again, but just in case I do, I would like to be able to....

Dave
 
C

codymanix

I figured out what the problem is. The InitializeComponent method is too

Maybe you got to the method size limit of the current CLR.
Iam curious. How many lines was your method?
Any ideas on what code if any can be moved out of the InitializeComponent
method to make it smaller?

Or a differant way to do this.

My GUI is for the most part finished, so I really dont need to open it in
designview again, but just in case I do, I would like to be able to....

It depends on how your gui is looks like? Do you have many Tabpages? If so,
make the contents of each Tabpage in a separate derived UserControl/Panel so
you can split up things a bit.
Generally it is a good idea to separate things, to make your code more
readable and maintainable.
Also if you have functionality/controls which is similar is different places
make it its own class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top