Type-Initialisation function for aM has caused an exception

GillianGillian Posts: 5
Hello,

I'm trying to do a schema compare with a backup file.
I followed the instructions on http://78.31.104.66/index.php/Schema_Ob ... ckup_SDK_8.

But when i run the code it shows the exception "Type-Initialisation function for aM has caused an exception".

my code:
        Public Shared Function RegisterBackup(ByVal filename As String, ByVal databaseName As String) As Global.RedGate.SQLCompare.Engine.ReadFromBackup.BackupSetDatabase
            Dim bdsBackup = New Global.RedGate.SQLCompare.Engine.ReadFromBackup.BackupDatabaseSource
            Dim files As New List(Of String)(1)
            files.Add(filename)
            bdsBackup.Files = files
            Dim bsdBackup As New Global.RedGate.SQLCompare.Engine.ReadFromBackup.BackupSetDatabase
            Dim cpBdsBackup As ConnectionProperties = bdsBackup.ToConnectionProperties
            bsdBackup.Register(cpBdsBackup, Global.RedGate.SQLCompare.Engine.Options.Default)

            Return bsdBackup
        End Function

When i call the ToConnectionProperties, i get the error.

When I "watch" the BackupDatabaseSource.
I see the error in the IsCaseSensitive property
In the Innerexception underneath that there is another error: Can't load one or more multiple types. Look at LoaderException property for more information.
So when i watch that. I get a specific error:
The method get_IsIncomplete in the type Redgate.BackupReader.BackupSet out of the assembly RedGate.BackupReader, Version=1.3.0.106, Culture=neutral, PublicKeyToken=7f465a1c156d4d57 does not have an implementation.

Note: I translated the errors from dutch to english. They could be slightly different.

How can I solve this issue?

Thanks in advance,
Gillian

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello,
    Are you trying to compare a SQL Backup file or a regular backup file? You may just need to reference RedGate.BackupReader.SqbReader.dll.
  • Hello,
    Are you trying to compare a SQL Backup file or a regular backup file? You may just need to reference RedGate.BackupReader.SqbReader.dll.

    Thank you for your reply

    I've already referenced Redgate.BackupReader.SqbReader.dll. Specific Version is set to false and i've added them locally.

    I'm trying to compare a .bak file which I created with SMO.
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Compiling the application as 32-bit (x86)? Because the backupreader DLL is 32-bit only.
  • I know, I'm compiling it as a x86..
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Have you also put RedGate.Shared.Utils.dll in the output folder? The BackupSet class implements IRedGateSerializable, which is in that assembly.
  • Yes,

    I've referenced:
    RedGate.BackupReader.dll
    RedGate.BackupReader.SqbReader.dll
    RedGate.Licensing.Client.dll
    RedGate.Shared.SQL.dll
    RedGate.Shared.Utils.dll
    RedGate.SQLCompare.ASTParser.dll
    RedGate.SQLCompare.Engine.dll
    RedGate.SQLCompare.Rewriter.dll
    RedGate.SQLDataCompare.Engine.dll

    I've also added the xml files.. Just trying.. But that doesn't work either..
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Maybe mismatched versions of some RedGate components. Did you replace any of the DLLS with versions from different packages? For instance, different versions of the assemblies exist in the SDK distribution compared to SQL and Data Compare.

    You may also have some outdated RedGate.* dlls in the GAC.
  • I have uninstalled "SQL Toolbelt", ran a Registery cleaner, checked if all files were deleted from the GAC. Rebooted, and installed "SQL Toolbelt" again.

    I added the "new" libraries, and it worked! :D

    Thank you very much for your support.
Sign In or Register to comment.