Solved

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

Posted on 2014-09-07
5
2,573 Views
Last Modified: 2016-09-18
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:Error while unloading appdomain. (Exception from HRESULT: 0x80131015)Commenting 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!
0
Comment
Question by:SqueezeOJ
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 500 total points
ID: 40308721
you need to execute below statement in Form Closing Event.

Me.rptExpenses.LocalReport.ReleaseSandboxAppDomain()
0
 

Author Closing Comment

by:SqueezeOJ
ID: 40308769
Excellent - Thanks!
0
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 40313812
Thanks @Netminder
0
 

Expert Comment

by:Jonathan Arias
ID: 41804130
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.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question