I am writing this program in .NET and i get this strange System.TypeInitilizationException when i start the exe from outside visual studio 2002 by double clicking on it.
However it runs fine when i start it from within VS.
This is on WinXP with .NET 1.0 & 1.1 (i have tried both but same problem),

I have Win2k installed on the same machine and it runs the program fine both from outside and inside VS.

I copied the file to a friends pc running WinXP with .net 1.1 and it ran fine,
Also the class during whose initialization it gives an error is an abstract class and does not have a static constructor.

Anyone knows any solutin to this problem.

Any hint or tries will be appreciated. I am desparate here. :(
Posted on 2004-01-16 18:26:19 by clippy
Ok i just noticed that if i change the name of the exe ,it runs perfectly fine outside vs.

e.g - if i change the name form myname.exe to mynae.exe it runs fine,

Now what can the problem be???
And how does just changing the name of the exe make it work correctly?
Posted on 2004-01-17 00:10:53 by clippy
Hi Clippy,

I've never seen that one. Do you have MSDN on your box? My first guess is that you have a namespace collision. I'm likely to be wrong, though.

Posted on 2004-01-17 10:51:27 by cdquarles
If there is a a namespace collision then just changing the name of the exe shouldnt have any impact on it. It should still give the same error. Also the program runs fine from within VS.

Yes, i have msdn and i have even checked all the online newsgroups but no info :(
Posted on 2004-01-18 22:05:49 by clippy
Hi Clippy,

Ok. Can you post/send the source code? I'll look up the exception name on my box to see what I can find out about it.

Posted on 2004-01-19 18:11:29 by cdquarles
Hi cdquqrles,
Sorry for the late reply. Got a bit busy.

The source code is way too big to post or to understand completly in one go.

I can explain you a bit about the error part though.

I have an abstract class State from which i inherit a few classes. The abstarct class has default virtual functions and it implements default behaviour for them in it. The derived classes can override and implement their own behaviour.

But when i try to initialize any of the derived classes , i get a System.TypeInitialization Exception in the base class ( called state ).

If i remove the initialization then it gives me the same exception on a call to Console.WriteLine. If i remove the initialization and the call to Console.WriteLine, the program runs fine. But strangely enough, the description for TypeInitialization Exception says that it occurs in classes having static constructors, which i dont have in any of my classes????
Posted on 2004-01-25 12:39:28 by clippy
Hi clippy,

I have started a new job, so I understand the situation (my new work week is 64 hours long with an hour's commute to and an hour's commute from work). OK, if I understand you correctly, you are calling the equivalent of mybase (or this) at some point in the construction of your derived class. Is this constructor parameterized? I would like to try to reproduce your error on my system. Is there any way to send a condensed version for me to try? You can send me a note throughhttp://www.asmcommunity.net/board/cryptmail.php?tauntspiders=in.your.face@nomail.for.you&id=1f36bb7616ce5d583f25e558fd96e597.

Posted on 2004-02-01 18:05:02 by cdquarles