How to: Debug a Business Logic Handler (Replication Programming)
新建日期: 2006 年 4 月 14 日
Use a business logic handler to invoke custom business logic when a merge subscription is synchronized. For more information, see 在合并同步期间执行业务逻辑.
The Merge Replication Reconciler (replrec.dll) calls the managed code assembly containing the business logic. In most cases, replrec.dll and the custom business logic is executed on the computer where the Merge Agent runs (at the Subscriber for a pull subscription or at the Distributor for a push subscription). In the case of Web synchronization, or in the case of a SQL Server Compact Edition (SQL Server 2005 Compact Edition) Subscriber, the reconciler and the custom business logic is executed on the Web server.
To debug a business logic handler on a local computer
Configure publishing and distribution, create a publication, and create a subscription to the publication. For more information, see 复制操作指南.
Create and register a business logic handler. For more information, see How to: Implement a Business Logic Handler for a Merge Article (RMO Programming).
Create a Replication Management Objects (RMO) project in Microsoft Visual Studio that programmatically starts the Merge Agent synchronously. For more information, see 如何同步请求订阅(RMO 编程).
Set a breakpoint in the business logic handler code, either in the method being debugged or in the class constructor. For more information about the methods that can be implemented in a business logic handler, see the BusinessLogicModule methods topic.
Build the business logic handler in debug mode and deploy the assembly and debugging symbol file (.pdb) in the location registered in step 1.
注意: To simplify debugging, create a single Visual Studio .NET solution that contains both the business logic handler project and the project that synchronizes the subscription. In this case, set the synchronization project as the startup project, and configure the build environment to deploy the business logic assembly to the location registered in step 1 during debugging. Execute insert, update, or delete commands against the subscription or publication database. The command and execution location depends on the method being debugged.
Start the project from step 3 in debug mode to synchronize the subscription.
Assuming that no other breakpoints are set and the proper commands are replicated, the execution stops when it reaches the breakpoint in the business logic handler.
To debug a business logic handler on a Web server using Web synchronization, or for a SQL Server Compact Edition Subscriber
Configure publishing and distribution, create a publication, and create a pull subscription to the publication. The publication must support Web synchronization or SQL Server 2005 Compact Edition Subscribers. For more information, see 复制操作指南 or 复制和 RDA 任务 (SQL Server Compact Edition).
Create and register a business logic handler. For more information, see How to: Implement a Business Logic Handler for a Merge Article (RMO Programming).
Set a breakpoint in the business logic handler code, either in the method being debugged or in the class constructor. For more information about the methods that can be implemented in a business logic handler, see the BusinessLogicModule methods topic.
Build the business logic handler in debug mode and deploy the assembly and debugging symbol file (.pdb) at the Web server in the location registered in step 1.
注意: If the business logic handler fails to build because the assembly is in use, type the command iisreset
on the Web server at the command prompt to reset the Web server.Synchronize the subscription with Web synchronization enabled. During synchronization, the Web server loads the registered assembly.
Using the Visual Studio .NET debugger, attach to the one of the following processes on the Web server:
- w3wp.exe - Windows Server 2003.
- inetinfo.exe - Windows 2000 and Windows XP.
In the Output window, check the debug output to verify that the symbols for the registered assembly loaded properly. If the symbols were not loaded, ensure that the correct .pdb file was copied in step 4, and repeat step 5.
Execute insert, update, or delete commands against the subscription or publication database. The command and execution location depends on the method being debugged.
Using the Visual Studio debugger, attach to the w3wp.exe process.
Synchronize the subscription again, using Web synchronization.
Assuming that no other breakpoints are set and the proper commands are replicated, the execution stops when it reaches the breakpoint in the business logic handler.
请参阅
任务
How to: Implement a Business Logic Handler for a Merge Article (Replication Programming)