Solved

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

Posted on 2014-09-07
5
2,704 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

696 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