ok. i've probably pinned it down.
thanks for your clues about threading and AppDomain (the AppDomain thing
came out to be very useful)
now the reason of all my stress:
first: users were absolutely sure that crash occurs just *after* splash
is shown... wrong, wrong, wrong! app crashed just *before* splash was
shown. being assured by the users that crash occurs after splash screen
is shown i was looking for crash reasons on the main thread that brings
to life my main form.
second: dump from AppDomain revealed that indeed we were dealing with
splash screen / threading related problem.
now came the easy part :) these two clues led me to the source of my
problems: main thread was trying to access splash screen whereas the
thread that the splash supposed to run on was not yet started. so the
static splash screen object was not yet created hence the
NullObjectReferenceException.
temporary solution was to return from static splash screen method if the
static splash screen was still a null.
the 'real' solution would be to block main thread (or queue splash
screen methods invoking) until splash is started. I'd probably choose
first solution - now i have to figure out how to do it the 'safe way'.
but there is still one thing - why this crashes were so random? it seems
that the crash was not related to the processor load. the only pattern
that came out was that app crashed almost always when it was started for
the first time after boot. it's like jitting taking too long or
something like that but related to the CLR? of course not all machines
reported such crashes.
anyway - thanks again Marc.
Marc Gravell wrote:
STA doesn't really (AFAIK) affect pure CLR code (which is fully threaded);
as I understand it, it only impacts external calls across OLE/COM etc. I
might be wrong ;-p
If I was a gambling man, I'd look at the code that initiates the splash
screen, or any events that are fired between them - but without postable
code it is hard to imagine exactly where the issue might be.
Ooh - one just popped in - perhaps the splash is trying to trigger an event
that the primary thread hasn't quite (on some CPUs) subscribed to yet, and
is doing:
SomeEvent(this, EventArgs.Empty);
instead of:
EventHandler handler = SomeEvent;
if(handler!=null) handler(this, EventArgs.Empty);
Just a thought.
Marc