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.
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.
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();
}
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();
}
User contributions licensed under CC BY-SA 3.0