tags:

views:

36

answers:

1

I have just got the following bloody MDA exception on a rather simple little program:

A SafeHandle or CriticalHandle of type 'Microsoft.Win32.SafeHandles.SafeCapiHashHandle' failed to properly release the handle with value 0x004E48C0. This usually indicates that the handle was released incorrectly via another means (such as extracting the handle using DangerousGetHandle and closing it directly or building another SafeHandle around it.)

I have never seen anything like this. My program code is:

public partial class SmsEditorForm : Form
{
    public SmsEditorForm()
    {
        InitializeComponent();
    }

    private void SmsEditorForm_Load(object sender, EventArgs e)
    {          
        using (var ents = new TemplateEntities())
        {
            templateCombo.DataSource = ents.NotificationTemplates.OrderBy(nt => nt.TemplateName).ToList();
            jobCardCombo.DataSource = ents.JobCards.Where(jc => !jc.JobDeleted && !jc.Archived).ToList();
        }
    }

    private void smsText_TextChanged(object sender, EventArgs e)
    {
        charCountLabel.Text = smsText.Text.Trim().Length.ToString();
    }

    private void templateCombo_SelectedIndexChanged(object sender, EventArgs e)
    {
        using (var ents = new TemplateEntities())
        {
            smsText.Text = ents.NotificationTemplates.Single(nt => nt.TemplateId == (int) templateCombo.SelectedValue).ExternalRecipientSms;
        }
    }
}
+3  A: 

Looks like a problem in your SMS library. In particular, whatever part of the code uses SafeCapiHashHandle (this is an encryption handle, so, e.g., using a web service over SSL would cause this).

Stephen Cleary
No it isn't. The SMS service is a web service, and if I click Continue on the error dialogue, it continues and sends the SMS perfectly.
ProfK
See updated answer.
Stephen Cleary