> put the following into a console app in .net 2.0, compile it in release mode
> and then run it 2 ways:
[quoted text clipped - 6 lines]
> This seems to be a problem with release mode and compiler optimisations:
> http://www.thescripts.com/forum/thread494282.html[^]
I don't understand your question. The link you provided includes clear
replies explaining that the issue is due to inlining and is not a
problem (except of course if you are writing code that doesn't take
inlining into account).
In C#, there's a code attribute that can be used to suppress inlining
for specific methods. I don't know if VB has something similar, but if
it does, then that would be the solution to your problem.
Otherwise, don't write code that assumes a method won't be inlined.
Pete
Iain Mcleod - 13 Sep 2007 09:28 GMT
Thanks Peter
This is exactly the attribute I was looking for:
<MethodImpl(MethodImplOptions.NoInlining)>
You're perfectly correct as well. You should never write code that relies
on inlining not taking place. Sadly my colleague who wrote a reflection
based data access layer had never heard of inlining until yesterday.
In fact, the project containing the offending data access layer had been in
production in release mode but in a web project - so obviously no inlining
was taking place. It was only when I reused the data access library in a
console app that the problem manifested itself.
I'm sure we're not the first to have fallen victim to this unpredictability.
Cheers
Iain
> > put the following into a console app in .net 2.0, compile it in release mode
> > and then run it 2 ways:
[quoted text clipped - 19 lines]
>
> Pete
You could likely test the number of frames to take into account possible
optimizations.
IMO your best is first to explain what you are trying to do...
--
Patrice
> put the following into a console app in .net 2.0, compile it in release
> mode and then run it 2 ways:
[quoted text clipped - 29 lines]
>
> End Module