Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now