System.Reflection.Emit.__ExceptionInfo.MarkFinallyAddr C# (CSharp) Method

MarkFinallyAddr() private method

private MarkFinallyAddr ( int finallyAddr, int endCatchAddr ) : void
finallyAddr int
endCatchAddr int
return void
        internal virtual void MarkFinallyAddr(int finallyAddr, int endCatchAddr) {
            if (m_endFinally!=-1) {
                throw new ArgumentException(Environment.GetResourceString("Argument_TooManyFinallyClause"));
            } else {
                m_currentState = State_Finally;
                m_endFinally=finallyAddr;
            }
            MarkHelper(finallyAddr, endCatchAddr, null, Finally);
        }

Usage Example

        public virtual void BeginFinallyBlock()
        {
            if (this.m_currExcStackCount == 0)
            {
                throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
            }
            __ExceptionInfo info         = this.m_currExcStack[this.m_currExcStackCount - 1];
            int             currentState = info.GetCurrentState();
            Label           endLabel     = info.GetEndLabel();
            int             endCatchAddr = 0;

            if (currentState != 0)
            {
                this.Emit(OpCodes.Leave, endLabel);
                endCatchAddr = this.m_length;
            }
            this.MarkLabel(endLabel);
            Label lbl = this.DefineLabel();

            info.SetFinallyEndLabel(lbl);
            this.Emit(OpCodes.Leave, lbl);
            if (endCatchAddr == 0)
            {
                endCatchAddr = this.m_length;
            }
            info.MarkFinallyAddr(this.m_length, endCatchAddr);
        }