Debugging Silverlight not hitting breakpoints
i am trying to develop a Silverlight application for a school project.
But I’m having problems with Visual Studio not loading the break point, making it very hard to debug a Silverlight application using ViewModels.
I have tried adding "Silverlight" under "Project Properties" -> "Web" -> "Silverlight", but this have done nothing.
It is strange because it wo开发者_运维知识库rks some times. I have tried using Chrome, Firefox and Internet Explorer. And with Silverlight 4 and 3.
Do any one know a solution for this?
I found that it helped if you set your default browser to IE (I've only used IE8 with Silverlight). That way, when you press F5, Visual Studio does seem to be able to connect up the debugger to the Silverlight plugin. You should then be able to use the VS debugger.
I certainly had difficulty trying to debug Silverlight applications with Firefox. Firefox runs plugins (including the Silverlight plugin) in a separate process, and I guess VS isn't smart enough to realise that Silverlight isn't running in the process it started. You can manually attach the VS debugger to the plugin-container process, but (if my memory serves me correctly), I didn't find this to always be reliable. I certainly found debugging a lot more reliable after switching my machine's default browser to IE.
Also, in your comment on Detroitpro's answer, you wrote
It is telling the that no symbols have been loaded even before i connect with a browser, so i don't think that is is that[...]
If you put a breakpoint in before you start your Silverlight app in a browser, then you probably will get a 'no symbols have been loaded' message. When you start debugging, Visual Studio will start the ASP.NET dev server, to serve up an HTML page that contains your Silverlight app if nothing more. The 'no symbols' message means that VS couldn't find the class you put the breakpoint in in any of the processes its debugger is connected to. (At this point, the only process the VS debugger is attached to is the ASP.NET dev server.) Once you open a browser to view a page containing your Silverlight app, and connect the VS debugger to the process running the Silverlight plugin, it should get rid of the 'no symbols' message.
Finally, another way of telling whether the VS debugger has connected to a process running your code is to bring up the Modules window (Debug > Windows > Modules). If your app's DLL isn't in the modules list, you'll get the 'no symbols have been loaded' message if you attempt to put breakpoints in your app's code.
You have to Attach the Plugin Container of Firefox to the Debugging Process, as Firefox is not running any Plugins within the main process anymore.
Go to Debug -> Attach to Process... -> Search for Plugin-Container and hit the Attach button.
Now debugging should work again.
Here's what worked for us with Internet Explorer 9
Start the project with Ctrl-F5.
Use the debug menu to attach to the browser process.
Stop the project.
Run the project with F5.
Here is the solution that worked for me when debugging was not working in Firefox:
- Type "about:config" into the address bar of Firefox
- Find the property named "dom.ipc.plugins.enabled"
- Change the value from true to false by double clicking
- Restart all Firefox browsers
- Go back to Visual Studio and start debugging!
I had this sample problem a few weeks ago; that's when I learned that Firefox and Chrome both have bugs that cause them not to be able to debug silverlight. Also, make sure you are using a newer version of IE. There is some random middle version of IE that won't load correctly either.
click debug->exceptions and check the thrown checkbox near the .net exceptions.
Just as an addition to the answers above, I've found that you can launch the application outside of the browser by right clicking the project and going to Properties. Then in the Silverlight tab select the tick box 'Enable running application out of the browser'. It should now hit the breakpoints you've set without you having to change your default browser or attaching to a specific process.
精彩评论