在dotnet核心中使用RMO在SQL 2012中创建发布时出现问题

时间:2020-07-07 07:54:34

标签: c# sql rmo

我正在尝试使用Microsoft.SqlServer.Rmo在Sql Server 2012中创建发布,但是在创建复制数据库时抛出未找到异常的方法。

            // Connect to the Publisher.
            if (conn.IsOpen)
                conn.Disconnect();
            conn.Connect();

            // Enable the AdventureWorks2012 database for transactional publishing.
            in the below line i am getting the method not found exceptions
            publicationDb = new ReplicationDatabase(publicationDbName,conn);

            // If the database exists and is not already enabled, 
            // enable it for transactional publishing.

            
            if (publicationDb.LoadProperties())[enter image description here][1]
            {
                if (!publicationDb.EnabledTransPublishing)
                {
                    publicationDb.EnabledTransPublishing = true;
                }
                // If the Log Reader Agent does not exist, create it.
                if (!publicationDb.LogReaderAgentExists)
                {
                    // Specify the Windows account under which the agent job runs.
                    // This account will be used for the local connection to the 
                    // Distributor and all agent connections that use Windows Authentication.
                    publication.SnapshotGenerationAgentProcessSecurity.Login = winLogin;
                    publication.SnapshotGenerationAgentProcessSecurity.Password = winPassword;

                    // Explicitly set authentication mode for the Publisher connection
                    // to the default value of Windows Authentication.
                    publicationDb.LogReaderAgentPublisherSecurity.WindowsAuthentication = false;

                    // Create the Log Reader Agent job.
                    publicationDb.CreateLogReaderAgent();
                }
            }
            else
            {
                throw new ApplicationException(String.Format(
                    "The {0} database does not exist at {1}.",
                    publicationDb, publisherName));
            }

error msg 1 error msg 2

0 个答案:

没有答案