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?
 
dejaanbuAuthor Commented:
ok. Finally i used Backup & Restore method of SMO.. it is fast and produces no errors.
0
 
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:
used alternative method
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.