Error while unloading appdomain. (Exception from HRESULT: 0x80131015) occurs when closing a form

2

I am using a login form to get a main form. Login form calls the main when the password is correct. Even if I commanded the login form to close, it doesnt show as closed, it remains minimized in the taskbar. But when i close the main form when its running the exception "Error while unloading appdomain. (Exception from HRESULT: 0x80131015)" is given. Please help.

c#
exception
appdomain
asked on Stack Overflow Feb 11, 2011 by HARSHANI • edited Feb 11, 2011 by sarnold

3 Answers

3

Winforms doesn't support AppDomains. It bombs because the form won't close. It doesn't even know it exists, it is in another AD. Don't try to make this work, only create forms in the default domain.

answered on Stack Overflow Feb 11, 2011 by Hans Passant
0

This is a reported Microsoft bug. There is a workaround for it - to call reportViewer.LocalReport.ReleaseSandboxAppDomain() method before closing the parent form.

Example:

     private void formname_FormClosing(object sender, FormClosingEventArgs e)
           {
               reportViewername.LocalReport.ReleaseSandboxAppDomain();
           }
answered on Stack Overflow Mar 14, 2013 by Sumon Banerjee
0

Modify what happens during the FormClosing event, in there you just have to add reportViewer1.Dispose();

protected override void OnFormClosing(FormClosingEventArgs e)
{
      base.OnFormClosing(e);
      reportViewer1.Dispose();
}
answered on Stack Overflow Nov 19, 2014 by user3849942 • edited Nov 19, 2014 by sǝɯɐſ

User contributions licensed under CC BY-SA 3.0