Document directory
- Solve the problem that Silverlight cannot be debugged.
Solve the problem that Silverlight cannot be debugged.
This article is from Kevin Yang's blog: Kevin Yang
Problem description
During the Silverlight development process, you may encounter problems that cannot be debugged by Silverlight from time to time. I have encountered the following situations:
1. Web application + Silverlight, F5 cannot follow up the breakpoint in the Silverlight program after it enters the debugging status
2. There are two Silverlight projects in the project. One of the Silverlight programs has a mouse click event to navigate the current page to the bearer page of another Silverlight program. The breakpoint of the first Silverlight program is normal, but the breakpoint in the second Silverlight program cannot be stopped automatically
3. Whether debugging in testpage mode or in web engineering, if the Silverlight debugging switch is enabled, the system prompts"Unable to start debugging. Cannot locate Microsoft Internet Explorer". If you run Ctrl + F5 directly, the same problem may occur sometimes.
Debugging fails for a single Silverlight Project
For the first question, check whether the following settings are correct:
1.Check that Silverlight debugging is enabled.. Double-click the properties folder in the ASP. Net project to open the property settings page and find the Web bar. There are several debugging options at the bottom of this page, as shown in:
Check that the check before the last "Silverlight" is checked.
2.Make sure that the xap package accessed by the browser is up-to-date. Check whether IE has cleared the cache, or the xap in clientbin fails to be updated for some reason (for example, it cannot be overwritten due to configuration management)
3.Check whether the ASP. Net project is bound to a Silverlight Application. You can use the Silverlight application page card on the Properties Panel of the Asp.net project to check whether the binding is successful. As follows:
4.Check whether startupobject of the Silverlight project is set correctly.. Sometimes we rename the project namespace, which will cause the entry object of the Silverlight application to become invalid, resulting in startup failure.
Cannot debug multiple Silverlight projects at the same time in IE8 ?!
IE8 is not the same as IE in the past. Its Multi-tag implementation adopts the multi-process method. The entire window is a framework process, and each tab is an independent sub-process (in fact, IE8 dynamically controls the number of tab processes based on the memory, therefore, multiple tabs may coexist in the same process ). When you try to open different Silverlight applications on multiple tabs, such as opening a new page from silverlightapplication1 to the silverlightapplication2 page, you will find that the silverlightapplication2 application cannot be debugged.
This is because,In addition to starting the Window Process, Visual Studio does not automatically attach other processes that contain the Silverlight application. If we need to add multiple tabs (or multiple Windows) to debug different Silverlight applications at the same time, we must manually attach these processes.
For example, I have two Silverlight projects. The link in silverlightapplication1 points to the silverlightapplication2 page. clicking the link will open the bearer page of silverlightapplication2 in the new tab.
To attach the corresponding process, we first need to find the process that silverlightapplication2 carries the page. Start processexplorer and we can see three processes.
The parent process (Framework process) whose ID is 4528 is used to manage transactions such as communication between different tag processes. 5160 and 5248 correspond to two tab processes respectively. We cannot determine which one corresponds to the process number here.
Open the attach window in Visual Studio (menu => DEBUG => attach to process ...)
The list of all processes available in the system is listed here. We can see three ie processes, one of which is gray, which indicates that the process has been attach to the Visual Studio debugger. If the Framework process 4258 is excluded, the process 5248 is left. This process is the process that hosts the page corresponding to silverlightapplication2 that we are looking. After the selection, attach to the debugger. We found that the breakpoint in silverlightapplication2 is still displayed as a hollow red circle and still cannot be debugged.
This is because the process code type we specified is incorrect. We have noticed that there is one of the top attach to, and the following is automatic. This indicates that the Visual Studio debugger will automatically help us select the debugging type of the process, such as hosting code debugging, or script debugging. We selected the process 5248 and found that Visual Studio chose script debugging for us.
In Visual Studio, script debugging and Silverlight debugging cannot coexist, Which is why Visual Studio prompts you when you press F5, debugging the Silverlight program temporarily disables the script debugging function. Therefore, in script debugging, we cannot follow up the breakpoint of the Silverlight application.
Additionally, disabling script debugging settings in IE8 advanced options does not affect Visual Studio at all, because Visual Studio 2008 automatically enables script debugging when the debugger starts (you can disable this feature through the Registry), unless Silverlight debugging is enabled in the Web application property.
Back to the problem we just encountered, because Visual Studio helped us to automatically select a wrong debugging type, we could not debug silverlightapplication2, so we need to manually specify the attach type. Click Select next to attach.
In the displayed select code type window, select Silverlight. After confirmation, attach again. We found that this time, the breakpoint actually works.
Of course, if this method is troublesome, we can also change the tab Process Creation Method of IE8 to make different tabs coexist in one process. There is a tabprocgrowth key value (DWORD type) under the Registry HKEY_CURRENT_USER/software/Microsoft/Internet Explorer/Main. When it is set to 0, the IE framework and Tab work in one process, tab is created in thread mode, and the protection mode of IE (protect mode) is disabled. When tabprocgrowth = 1, the IE framework and Tab work in different processes. When tabprocgrowth> 1, this value determines the maximum number of tab processes created by IE8. If tabprocgrowth does not exist, the number of tab processes is determined based on the number of available physical memory.
The IE window cannot be opened during debugging
I have encountered this problem recently. I don't know why, suddenly, my Silverlight project cannot be debugged when I press F5. The following dialog box is displayed: unable to start debugging. cannot locate Microsoft Internet Explorer.
If you run it directly, you can open it. However, Visual Studio still displays the same error.
I tried to restart my computer, reinstall Silverlight tools, create a clean test project, and modify the default browser of the system and Visual Studio (note, the default browser of the system and Visual Studio is set independently. Google has been around for a long time. Many posts on the Silverlight official forum are related to this, but I have carefully read it and found that no reply can solve my problem. A guy who posted a post solved the problem, but he ran away without explaining how to solve it. He strongly liked BS!
Finally, how did I solve this problem? I used the Process Monitor Tool (which is officially delivered by Microsoft sysinternal !). The worker process then finds that the process tries to access a non-existent file.
Process Monitor, which can monitor the activities of all processes in the current system, including operations on the file system, reading and writing the registry, network access, and thread activity. It is a very practical debugging and maintenance tool.
Open this tool and select devenv.exe. Start debugging in Visual Studio F5. The error dialog box is displayed immediately. OK. Pause pm. Otherwise, there are too many entries.
However, there are still too many event entries, So I filtered out the results for success, because we only focus on those failed entries.
Then the log entries are carefully checked and the root cause of the problem is discovered:
Originally, Visual Studio will read the HKLM/software/Microsoft/Windows/CurrentVersion/APP paths/iexplore.exe item in the Registry during debugging or running, and then cannot read it, so the error is reported. No wonder the message "cannot locate Microsoft Internet Explorer" is displayed.
I open the Regedit Registry Editor, find this path, add the missing items, and return to Visual Studio F5. Finally, I can see it ~
I hope that my solution will inspire you. if you encounter a similar and inexplicable problem in the future, you can use the PM tool to troubleshoot the problem.
Update: update the new symptoms (the cannot locate Microsoft Internet Explorer dialog box is displayed during F5 debugging.