none
MS SQL 2012 - Error when create a publication for replication transaction

    Question

  • Hi,

       I'm working on SQL 2012. My OS is Windows 2008. When I created a publication for a replication transaction, snapshot agent failed as below error:

    "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. ---

    ".

    Could you help me to resolve this issue ?

    Thanks


    • Edited by Valiant1982 Thursday, July 18, 2013 2:31 AM Update OS
    Wednesday, July 17, 2013 11:31 AM

Answers

  • There is a windows update that just came out that causes this issue.

    NET update KB2840628 on Server 2008 R2 x64

    Uninstall this Update and Restart the machine and this should solve your issue.

    • Proposed as answer by LBHJ Monday, July 22, 2013 7:03 PM
    • Marked as answer by Valiant1982 Monday, July 29, 2013 7:29 AM
    Monday, July 22, 2013 7:03 PM

All replies

  • Your issue seems to be similar as already discussed in the below link in forum...

    Let us if the below resolves your issue, if not please share more details.....like any message in event log or detailed error log file

    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/c2e90264-7d8b-42af-b109-ac5d4735d51e/transactional-replication-error

    The error messages were not very informative based on which I only searched very few clues that might be related to this problem. You can first take a look at:

    1. .NET Framework corruption

    You can refer to this blog,http://blogs.msdn.com/b/astebner/archive/2008/08/28/8904493.aspx to remove your existing .NET Framework 2.0 and 3.5 from your system and then install them again.

    2. Performance counters information corruption

    Check and rebuild your performance counters according to this KB article, http://support.microsoft.com/kb/300956

    3. Anti-virus software's issue

    Sometimes, an anti-virus software may over protect your computer which causes an application unexpectedly not working. You may turn off/Uninstall (if turn off not working) your anti-virus software temporarily to see if this issue will disappear.


    Please click the Mark as answer button and vote as helpful if this reply solves your problem

    Wednesday, July 17, 2013 1:04 PM
  • Hi,

        My issue was not resolved. This is detail my log:

    "

    Error messages:

    <dir></dir><dir>

    Message: 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. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.MethodAccessException: Attempt by method 'System.Configuration.TypeUtil.CreateInstanceRestricted(System.Type, System.Type)' to access method 'System.Diagnostics.SwitchElementsCollection..ctor()' failed. ---> System.Security.SecurityException: Request failed.
    System.Security.SecurityException:
    at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed)
    at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
    at System.Security.PermissionListSet.CheckSetDemandWithModification(PermissionSet pset, PermissionSet& alteredDemandSet, RuntimeMethodHandleInternal rmh)
    at System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandleInternal rmh)
    at System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantS
    ...
    System.TypeInitializationException:
    at System.Data.SqlClient.SqlConnection..ctor()
    at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
    at Microsoft.SqlServer.Replication.TransSqlClrCodeGenerators.ScriptDropReconciliationProcedure(SqlInt32 articleId, CustomStoredProcedureType customProcedureType)
    at Microsoft.SqlServer.Replication.TransSqlC...
    A .NET Framework error occurred during execution of user-defined routine or aggregate "sp_scriptdropdelreconciliationproc_sqlclr":
    System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.MethodAccessException: Attempt by method 'System.Configuration.TypeUtil.CreateInstanceRestricted(System.Type, System.Type)' to access method 'System.Diagnostics.SwitchElementsCollection..ctor()' failed. ---> System.Security.SecurityException: Request failed.
    System.Security.SecurityException:
    at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed)
    at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
    at System.Security.PermissionListSet.CheckSetDemandWithModification(PermissionSet pset, PermissionSet& alteredDemandSet, RuntimeMethodHandleInternal rmh)
    at System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandleInternal rmh)
    at System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantS
    ...
    System.TypeInitializationException:
    at System.Data.SqlClient.SqlConnection..ctor()
    at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
    at Microsoft.SqlServer.Replication.TransSqlClrCodeGenerators.ScriptDropReconciliationProcedure(SqlInt32 articleId, CustomStoredProcedureType customProcedureType)
    at Microsoft.SqlServer.Replication.TransSqlC...
    Command Text: if object_id('sys.sp_replcleanupccsprocs') < 0 exec sp_replcleanupccsprocs @publication
    Parameters: @publication = Test

    Stack: at Microsoft.SqlServer.Replication.AgentCore.ReMapSqlException(SqlException e, SqlCommand command)
    at Microsoft.SqlServer.Replication.AgentCore.AgentExecuteNonQuery(SqlCommand command, Int32 queryTimeout)
    at Microsoft.SqlServer.Replication.AgentCore.ExecuteDiscardResults(CommandSetupDelegate commandSetupDelegate, Int32 queryTimeout)
    at Microsoft.SqlServer.Replication.Snapshot.TransSnapshotProvider.CleanCCSCompensationProcsCommand(SqlConnection connection)
    at Microsoft.SqlServer.Replication.RetryableSqlServerTransactionManager.ExecuteTransaction(Boolean bLeaveTransactionOpen)
    at Microsoft.SqlServer.Replication.Snapshot.TransSnapshotProvider.DoConcurrentPostArticleFilesGenerationProcessing()
    at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.GenerateSnapshot()
    at Microsoft.SqlServer.Replication.SnapshotGenerationAgent.InternalRun()
    at Microsoft.SqlServer.Replication.AgentCore.Run() (Source: MSSQLServer, Error number: 6522)
    Get help: http://help/6522

    Server PROJECT35\SGI_DB, Level 16, State 1, Procedure sp_scriptdropdelreconciliationproc_sqlclr, Line 0
    A .NET Framework error occurred during execution of user-defined routine or aggregate "sp_scriptdropdelreconciliationproc_sqlclr":
    System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.MethodAccessException: Attempt by method 'System.Configuration.TypeUtil.CreateInstanceRestricted(System.Type, System.Type)' to access method 'System.Diagnostics.SwitchElementsCollection..ctor()' failed. ---> System.Security.SecurityException: Request failed.
    System.Security.SecurityException:
    at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed)
    at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
    at System.Security.PermissionListSet.CheckSetDemandWithModification(PermissionSet pset, PermissionSet& alteredDemandSet, RuntimeMethodHandleInternal rmh)
    at System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandleInternal rmh)
    at System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantS
    ...
    System.TypeInitializationException:
    at System.Data.SqlClient.SqlConnection..ctor()
    at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
    at Microsoft.SqlServer.Replication.TransSqlClrCodeGenerators.ScriptDropReconciliationProcedure(SqlInt32 articleId, CustomStoredProcedureType customProcedureType)
    at Microsoft.SqlServer.Replication.TransSqlC... (Source: MSSQLServer, Error number: 6522)
    Get help: http://help/6522

    </dir>

    Server PROJECT35\SGI_DB, Level 16, State 1, Procedure sp_scriptdropdelreconciliationproc_sqlclr, Line 0
    A .NET Framework error occurred during execution of user-defined routine or aggregate "sp_scriptdropdelreconciliationproc_sqlclr":
    System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.MethodAccessException: Attempt by method 'System.Configuration.TypeUtil.CreateInstanceRestricted(System.Type, System.Type)' to access method 'System.Diagnostics.SwitchElementsCollection..ctor()' failed. ---> System.Security.SecurityException: Request failed.
    System.Security.SecurityException:
    at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed)
    at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
    at System.Security.PermissionListSet.CheckSetDemandWithModification(PermissionSet pset, PermissionSet& alteredDemandSet, RuntimeMethodHandleInternal rmh)
    at System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandleInternal rmh)
    at System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantS
    ...
    System.TypeInitializationException:
    at System.Data.SqlClient.SqlConnection..ctor()
    at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
    at Microsoft.SqlServer.Replication.TransSqlClrCodeGenerators.ScriptDropReconciliationProcedure(SqlInt32 articleId, CustomStoredProcedureType customProcedureType)
    at Microsoft.SqlServer.Replication.TransSqlC... (Source: MSSQLServer, Error number: 6522)
    Get help: http://help/6522

    "

       How are other ideas?

    • Proposed as answer by LBHJ Monday, July 22, 2013 7:01 PM
    • Unproposed as answer by LBHJ Monday, July 22, 2013 7:01 PM
    • Proposed as answer by LBHJ Monday, July 22, 2013 7:04 PM
    Thursday, July 18, 2013 9:41 AM
  • There is a windows update that just came out that causes this issue.

    NET update KB2840628 on Server 2008 R2 x64

    Uninstall this Update and Restart the machine and this should solve your issue.

    • Proposed as answer by LBHJ Monday, July 22, 2013 7:03 PM
    • Marked as answer by Valiant1982 Monday, July 29, 2013 7:29 AM
    Monday, July 22, 2013 7:03 PM
  • Thanks! Uninstalling that update fixed the issue for me.
    Monday, July 29, 2013 3:51 AM
  • Hi I also had this problem, and uninstalling KB2840628 fixed the issue.

    But you need to block KB2840628, otherwise it will just come back again with Windows Update.

    I used this link to block it:

    http://www.ghacks.net/2010/08/11/how-to-block-specific-updates-in-windows-update/

    • Edited by rune0071 Saturday, August 03, 2013 12:52 PM edit
    Thursday, August 01, 2013 8:47 AM