.NET error when trying to create snapshot for transactional Replication

replicationsnapshottransactional-replication

I encountered a bizarre prob today while creating a transactional publication on a SQL 2012 server running on Windows Server 2008R2.

I had just had some success creating and initializing some Merge publications (including generating snapshots) on this same server.

With my transactional publication though, around the time the snapshot agent goes to lock tables, it gives me this:

A .NET Framework error occurred during execution of user-defined routine or aggregate "sp_scriptdropinsreconciliationproc_sqlclr":

System.TypeInitializationException: The type initializer for >'System.Data.SqlClient.SqlConnection' threw an exception. —

Here are some things I tried:

  • Google: surprisingly few results. A reference to KB2840628, which is
    not on the system.
  • Search here: nothing found
  • Manually create subscription thru the GUI (had
    been using a script) – fail
  • Same as above but publish from a
    different database – fail

In these tests I am using ridiculously
powerful accounts to try to rule out permissions issues.

It's very strange. Any helpful hints would be appreciated.

Best Answer

The error:

System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection'

is typically (in my experience!) indicative of a mismatch between the version of .Net on the machine initiating the connection, and the target machine.

Ensure both machines have the same version of the .Net distributable.