Attempted to access an unloaded AppDomain in SMO Transfer in ASP.Net

hello all,

i have a module which creates a new database from the existing database by copying all tables and objects from the existing db. i am achieving this thru SMO Transfer . some times, it works fine. it throws error some time.

ERROR : errorCode=0 description=Attempted to access an unloaded AppDomain. helpFile=TableTransferGenerator Task helpContext=0 idofInterfaceWithError={8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}

what is the cause of this error ? how can i solve this. somebody pls suggest..

note:- if i close .Net IDE and reopen, and then run the project..it works.(!).

Thanks for any help.
LVL 14
dejaanbuAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TempDBACommented:
From the error and the fix it is clear that when you are calling some functionality\use some dll, it is already unloaded and you need to reintialize the object. When you close your application and restart it, it does. So, probably there is either some exception which is not handled or you are not closing the application after the module is unloaded.
0
dejaanbuAuthor Commented:
Thanks for ur comment. here is the code i am using. can you pls point out where i am doing wrong? (it works fine most of the time..it displays that error some times! ..at that time, the db is created..transfer is not executing).

Try
Dim MasterDbse As String = "MY SOURCE DB"
Dim strDatabaseName as String="The new DB NAME"
            Dim conn As New ServerConnection("MY_SERVER")

            conn.LoginSecure = False

            conn.Login = dbUser

            conn.Password = dbPass



            Dim serverCon As New Server(conn)

            Dim newdb As New Database(serverCon, strDatabaseName)

            newdb.Create()
 Dim transfer As New Transfer(serverCon.Databases(MasterDbse))

            With transfer

                .CopyAllObjects = True

                .CopyAllTables = True

                .CopyData = True

                .CopyAllUsers = True

                .DestinationDatabase = newdb.Name

                .DestinationLoginSecure = False

                .DestinationLogin = dbUser

                .DestinationPassword = dbPass

                .DestinationServer = serverCon.Name

                 .CopySchema = True



            End With



            With transfer.Options

                .WithDependencies = True

                .ContinueScriptingOnError = True

                .NoIdentities = False

                .NoCollation = True

                .Default = True

                .Indexes = True

                .DriDefaults = True

                .DriAllKeys = True

                .DriForeignKeys = True

                .DriIndexes = True

                .DriPrimaryKey = True

                .DriUniqueKeys = True



            End With



            transfer.TransferData()
 ' in this line, it points the error in my error log
           
Catch ex as Exception
ErrorLog(ex.Tostring)
End Try

Open in new window

0
dejaanbuAuthor Commented:
ok. Finally i used Backup & Restore method of SMO.. it is fast and produces no errors.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dejaanbuAuthor Commented:
used alternative method
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.