Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: Creating object stops execution of entire function Pin
__DanC__26-Jun-07 5:25
__DanC__26-Jun-07 5:25 
GeneralRe: Creating object stops execution of entire function Pin
Nissim Salomon26-Jun-07 5:46
Nissim Salomon26-Jun-07 5:46 
GeneralRe: Creating object stops execution of entire function Pin
Hesham Yassin26-Jun-07 7:46
Hesham Yassin26-Jun-07 7:46 
GeneralRe: Creating object stops execution of entire function Pin
Luc Pattyn26-Jun-07 5:33
sitebuilderLuc Pattyn26-Jun-07 5:33 
GeneralRe: Creating object stops execution of entire function Pin
__DanC__26-Jun-07 5:37
__DanC__26-Jun-07 5:37 
GeneralRe: Creating object stops execution of entire function Pin
Luc Pattyn26-Jun-07 5:49
sitebuilderLuc Pattyn26-Jun-07 5:49 
GeneralRe: Creating object stops execution of entire function Pin
__DanC__26-Jun-07 5:55
__DanC__26-Jun-07 5:55 
GeneralRe: Creating object stops execution of entire function Pin
Luc Pattyn26-Jun-07 6:22
sitebuilderLuc Pattyn26-Jun-07 6:22 
__DanC__ wrote:
I would expect it to fail at the point of referencing the assembly but at least execute the function calls above it.


I understand that is what would be expected, but when you reach the Init() method, the
first thing that happens is the JIT compiles it; so it wonders about the
MyObject class, it must locate it, and at some point in time, also statically initialize it.
I am not sure exactly when that is supposed to happen; it must be deterministic of course,
and I know the exact order is surprisingly complex; long time ago I suffered from
a bug in that area, dont recall whether it was in 1.0 or 1.1 tho.

I think it is safe to assume static constructors get executed at the start of the
calling method (your Init), since the JIT in general must cope with a complex
flow graph and multiple references to the class, so it cannot always
(and hence does not even try to) predict which one will occur first, hence it will go
for early initialization.

You could proof this true or false by pushing the MyObject stuff and following code
inside Init() one level deeper...

Smile | :)




QuestionC# custom event handlers/controls Pin
donovan.solms26-Jun-07 2:43
donovan.solms26-Jun-07 2:43 
AnswerRe: C# custom event handlers/controls Pin
originSH26-Jun-07 4:10
originSH26-Jun-07 4:10 
GeneralRe: C# custom event handlers/controls Pin
donovan.solms26-Jun-07 5:14
donovan.solms26-Jun-07 5:14 
GeneralRe: C# custom event handlers/controls Pin
originSH26-Jun-07 5:38
originSH26-Jun-07 5:38 
GeneralRe: C# custom event handlers/controls Pin
donovan.solms26-Jun-07 6:01
donovan.solms26-Jun-07 6:01 
GeneralRe: C# custom event handlers/controls Pin
originSH26-Jun-07 6:24
originSH26-Jun-07 6:24 
GeneralRe: C# custom event handlers/controls Pin
donovan.solms26-Jun-07 10:40
donovan.solms26-Jun-07 10:40 
GeneralRe: C# custom event handlers/controls Pin
originSH26-Jun-07 22:11
originSH26-Jun-07 22:11 
GeneralRe: C# custom event handlers/controls Pin
led mike26-Jun-07 5:39
led mike26-Jun-07 5:39 
GeneralRe: C# custom event handlers/controls Pin
donovan.solms26-Jun-07 5:59
donovan.solms26-Jun-07 5:59 
GeneralRe: C# custom event handlers/controls Pin
led mike26-Jun-07 6:13
led mike26-Jun-07 6:13 
AnswerRe: C# custom event handlers/controls Pin
Dave Kreskowiak26-Jun-07 5:37
mveDave Kreskowiak26-Jun-07 5:37 
QuestionPlease correct the error..... Pin
help as an alias26-Jun-07 2:16
help as an alias26-Jun-07 2:16 
AnswerRe: Please correct the error..... Pin
Manas Bhardwaj26-Jun-07 2:19
professionalManas Bhardwaj26-Jun-07 2:19 
AnswerRe: Please correct the error..... Pin
Colin Angus Mackay26-Jun-07 2:21
Colin Angus Mackay26-Jun-07 2:21 
AnswerRe: Please correct the error..... Pin
kubben26-Jun-07 2:22
kubben26-Jun-07 2:22 
GeneralRe: Please correct the error..... Pin
Colin Angus Mackay26-Jun-07 2:23
Colin Angus Mackay26-Jun-07 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.