SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Database Replication - generating initial snapshot programmatically fails


Database Replication - generating initial snapshot programmatically fails

Author
Message
js 48709
js 48709
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 7

Greetings, trying to generate an initial snapshot in VB.Net (VS2012, .Net FW 4.6.1) following the steps given in http://www.yaldex.com/sql_server/progsqlsvr-CHP-19-SECT-1.html
Here is the code:

Public Function GenerateInitialSnapshot(ByVal conn As ServerConnection, ByVal InPublisherInstanceName As String, ByVal InPublicationDbName As String, ByVal InPublicationName As String, ByVal InReplicationDBName As String) As Boolean

Try

Dim sga As SnapshotGenerationAgent = New SnapshotGenerationAgent()
sga.Publisher = InPublisherInstanceName
sga.PublisherDatabase = InPublicationDbName
sga.Publication = InPublicationName
sga.Distributor = InPublisherInstanceName
sga.PublisherSecurityMode = SecurityMode.Integrated
sga.DistributorSecurityMode = SecurityMode.Integrated
sga.ReplicationType = ReplicationType.Merge

sga.GenerateSnapshot()

Return True

Catch ex As Exception
' Implement custom application error handling here.
Throw New ApplicationException(String.Format( _
"The snapshot from publication {0} could not be generated.", InPublicationName), ex)
End Try

Return False

End Function

The call to GenerateSnapshot fails with error -2146233036 "The type initializer for 'Microsoft.SqlServer.Replication.StringResources' threw an exception." The inner exception is -2146232832 "The native replication resource dll failed to load."
The registry setting VerSpecificRootDir is set to C:\Program Files (x86)\Microsoft SQL Server\130\ and I have copied C:\Program Files\Microsoft SQL Server\130\COM\Resources\1033\REPLRES.rll to C:\Program Files\Microsoft SQL Server\130\COM\REPLRES.rll but I still cannot get past this problem.

The stack trace shows:

at Microsoft.SqlServer.Replication.ReplMessage..ctor(Exception e)
at Microsoft.SqlServer.Replication.HistoryMessage..ctor(Exception e)
at Microsoft.SqlServer.Replication.SnapshotGenerationAgent.SnapshotGenerationAgentMessageFactory.CreateAgentMessage(Exception e)
at Microsoft.SqlServer.Replication.AgentCore.LogMessage(Exception e)
at Microsoft.SqlServer.Replication.AgentCore.ThreadFailedHandler(Exception e)
at Microsoft.SqlServer.Replication.AgentCore.Run()
at Microsoft.SqlServer.Replication.SnapshotGenerationAgent.GenerateSnapshot()
at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in C:\Users\John\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb:line 16
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
at System.Windows.Forms.Nativewindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Any help will be greatly appreciated!


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search