This article is reproduced in: CS frame network http://www.csframework.com/archive/2/arc-2-20110829-1811.htm
C #. Net component development-use Attach to Process to debug the designer code in real time
There are two debugging objects for Component Design: Component itself (Component/Control) and Component Designer (Component Designer/Control Designer ). You only need to set a breakpoint to run the program to debug the debugging component. Because the component designer works during design rather than runtime, you cannot set a breakpoint to debug the component.
In most cases, developers use MessgeBox to pop up information for debugging. This is a simple and reliable method, but they cannot access the code for real-time debugging, which hinders the development progress, there is an optimal solution, which supports real-time debugging during running through the Attach to Process method in the Debug menu.
Attach to Process startup method:
For differences between components and controls, see
Differences between controls and components (difference between Control and Component)
Http://www.csframework.com/archive/2/arc-2-20110630-1675.htm
Component Programming Model diagram:
Attach to Process:
Under the Debug menu of vs ide, Attach to Process is used to append an application in a Process to the VS debugging environment and Debug the application, the significance of this technology is that the application running and VS debugging environments can be separated. Generally, application Debugging starts and ends together with the debugging environment. Each debugging requires restarting the application from the beginning. If you only want to debug a specific scenario of the application, You have to waste time promoting it to debug the application. If we start an application outside of vs ide, the application will be added to vs ide through Attach. You will not interrupt the operation of the application multiple times when you start the IDE.
Attach to Process:
1. Run two VS development environments to open the same solution, for example:
2. Set the debugging breakpoint in solution 2 (B), for example:
3. Open the Debug \ Attach to Process menu in solution 2 (B), for example:
4. Attach to Process form, select the devenv.exe Process in Available processes.
Note: we have just opened two vssolutions. Theoretically, two devenv.exe files are correct. Why is there only one? The reason is that the devenu process in the current solution does not support debugging and cannot be attached to its own process for debugging.
Select devenv.exe and click Attach, for example:
5. automatically enters the running (debugging) status after Attach to Process:
6. Switch to solution 1 (A) to design components, for example, "generate the design time code of MyNodeComponent ".
7. when running to the Code where the breakpoint is set, the second solution (B) is automatically activated, and the real-time debugging status is displayed. We can view the Real-Time content of the component or object.
8. However, you cannot modify the code in the debugging status. Otherwise, the Edit and Continue dialog box is displayed.
Copyright: Framework network for C/S, Author: Sun Zhonglu. If you reprint it, please indicate the source.