Link to home
Start Free TrialLog in
Avatar of SqueezeOJ
SqueezeOJFlag for United States of America

asked on

How to fix "Error while unloading appdomain." error in VB.net?

Hello,

Using VB.net in VS2010.

I have a Main form and then a Reports form.  This Reports form has a ReportViewer, called rptExpenses.  When I load the Reports form, the following code runs:
Private Sub frmReports_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim SQLText As String = "SELECT * FROM expenses"
        Dim SQLData As DataTable = DBGetTable(SQLText)
        Me.rptExpenses.LocalReport.DataSources.Clear()
        Dim rprtDTSource As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource(SQLData.TableName, SQLData)
        Me.rptExpenses.LocalReport.DataSources.Add(rprtDTSource)
        Me.rptExpenses.LocalReport.ReportPath = "C:\Users\Jason\Documents\Visual Studio 2010\Projects\Remote-Expense\Remote-Expense\Report1.rdlc"
        Me.rptExpenses.RefreshReport()
    End Sub

Open in new window

Here's the problem: Everything works fine, however, when I exit the entire application (not the Reports form), I get the following error:

Error while unloading appdomain. (Exception from HRESULT: 0x80131015)
Screenshot:User generated imageCommenting out this one line removes the error:
Me.rptExpenses.LocalReport.ReportPath = "C:\Users\Jason\Documents\Visual Studio 2010\Projects\Remote-Expense\Remote-Expense\Report1.rdlc"

Open in new window

[u]Questions:[/u]
What am I doing wrong?
And how can I fix it?


Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Kalpesh Chhatrala
Kalpesh Chhatrala
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SqueezeOJ

ASKER

Excellent - Thanks!
Thanks @Netminder
Avatar of Jonathan Arias
Jonathan Arias

Hola amigo buenas tardes, te saludo desde Colombia, aplicando la solución que tu aportas al problema del compañero, a mi me sale un error con el código.
Me.rptExpenses.LocalReport.ReleaseSandboxAppDomain() = rptExpenses me aparece como error y no me deja soluciona la falla. es la misma expuesta por el compañero primero. Agradezco su colaboración.