illegalPrepareConstrainedRegion MDA

The illegalPrepareConstrainedRegion مدارة تصحيح الأخطاء assistant (MDA) هو activated when a RuntimeHelpers.PrepareConstrainedRegions أسلوب يتصل does not immediately precede the try كشف of the ‏‏ استثناء handler. This restriction هو at the MSIL المستوى, so it هو permissible إلى have non-تعليمات برمجية-generating المصدر between the يتصل و the try, such كـ تعليقات.

الأعراض

A constrained execution منطقة (CER) that هو ‏‏مطلقاً treated كـ such, but كـ a simple ‏‏ استثناء handling حظر (finally أو catch). كـ a consequence, the منطقة does not تشغيل في the حدث of an خارج-of-ذاكرة شرط أو a مؤشر ترابط إيقاف قبل الاكتمال.

السبب

The preparation نقش for a CER ليس followed correctly. This هو an خطأ حدث. The PrepareConstrainedRegions أسلوب يتصل used إلى mark ‏‏ استثناء handlers كـ introducing a CER في their catch/finally/fault/filter blocks must be used immediately قبل the try كشف.

الدقة

Ensure that the يتصل إلى PrepareConstrainedRegions happens immediately قبل the tryكشف.

التأثير تشغيل وقت التشغيل

MDA هذا أي تأثير تشغيل CLR.

الإخراج

The MDA displays the اسم of the أسلوب calling the PrepareConstrainedRegions أسلوب, the MSIL offset, و a رسالة indicating the يتصل does not immediately precede the beginning of the try حظر.

التكوين

<mdaConfig>
  <assistants>
    <illegalPrepareConstrainedRegion/>
  </assistants>
</mdaConfig>

مثال

The following تعليمات برمجية مثال demonstrates the نقش that causes this MDA إلى be activated.

void MethodWithInvalidPCR()
{
    RuntimeHelpers.PrepareConstrainedRegions();
    Object o = new Object();
    try
    {
        …
    }
    finally
    {
        …
    }
}

راجع أيضًا:

المرجع

MarshalAsAttribute

PrepareConstrainedRegions

المبادئ

تشخيص الأخطاء مع المساعدين التصحيح مدارة

تنظيم إمكانية التشغيل المتداخل