Thanks. I couldn’t use “nop” because then the CLR considers the
program invalid because control flow can move off the bottom of the
method, even if the nop is unreachable. I also tried “ret”, but then
PEVerify complains that the return value is not on the stack. I also
tried an unconditional branch back to the start of the method, but
somehow PEVerify wasn’t happy with that either (stack depth are
supposedly inconsistent). I haven’t tried “endfinally” but I suspect
it would complain that the “endfinally” is not inside a finally block.

Using null works, thanks. I wonder, though, whether you realise how
undiscoverable that is to someone who doesn’t know, and how easily a
little documentation comment on “HandlerEnd” could have made it
discoverable and thus could have made it unnecessary for me to ask
here.

Thanks!
Timwi

On May 24, 2:45 pm, Jb Evain <[email protected]> wrote:
> On Mon, May 24, 2010 at 3:21 PM, Timwi <[email protected]> wrote:
> > If I want to create a “finally” block, apparently I have to set
> > HandlerStart to the first instruction, but HandlerEnd to the *next*
> > instruction following the last one. What do I do if the “finally”
> > block is supposed to be at the end of the method, i.e. there is no
> > next instruction?
>
> You can leave the HandlerEnd to null, it will be emitted as
> last_offset + 1. Or you can use a endfinally, or a nop as a marker.
>
> --
> Jb Evain  <[email protected]>
>
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to