简体   繁体   English

在 Visual Studio 2010 中调试 Silverlight

[英]Debugging Silverlight in Visual Studio 2010

I have an MVC application which uses a silverlight control.我有一个使用 silverlight 控件的 MVC 应用程序。

Somewhere along the line something is happening in the silverlight cs code that isn't right. silverlight cs 代码中发生了一些不正确的事情。 I've inserted break points in the CS silverlight code to get a better idea of what's happening, but for some reason I just can't step through the code.我在 CS silverlight 代码中插入了断点,以便更好地了解正在发生的事情,但由于某种原因,我无法单步执行代码。

I know code is being hit, but it's just not showing me in the debugger.我知道代码正在被命中,但它只是没有在调试器中显示我。

I thought it might be because I was using Chrome as the default browser but I changed this to Internet Explorer and still no joy.我认为这可能是因为我使用 Chrome 作为默认浏览器,但我将其更改为 Internet Explorer,但仍然没有乐趣。

I realize this is a very vague question, but has anyone else experience anything similar, and if so, how did you get around it?我意识到这是一个非常模糊的问题,但有没有其他人经历过类似的事情,如果有,你是如何解决的?

Any help would be appreciated,任何帮助,将不胜感激,

Thanks.谢谢。

Be sure to set the Silverlight Debugging checkbox on the project properties Web tab请务必在项目属性 Web 选项卡上设置 Silverlight 调试复选框

If Chrome is your default browser and your breakpoint tooltip shows this message:如果 Chrome 是您的默认浏览器并且您的断点工具提示显示此消息:

"The breakpoint will not currently be hit. No symbols have been loaded for this document" “当前不会命中断点。没有为此文档加载任何符号”

... then it is possible the debugger attached to the wrong Chrome process at debug startup. ...那么调试器可能会在调试启动时附加到错误的 Chrome 进程。 A work-around is:一种解决方法是:

  1. Start debugging your Silverlight app.开始调试您的 Silverlight 应用程序。 Your app should be running in Chrome.您的应用应该在 Chrome 中运行。
  2. From the Debug menu, select Attach to Process...从调试菜单中,select 附加到进程...
  3. Scroll through the available processes and locate the chrome.exe process that shows the type as 'Silverlight x86'.滚动浏览可用进程并找到显示类型为“Silverlight x86”的 chrome.exe 进程。

  4. Select that process and click Attach. Select 处理并单击附加。

I had firefox as my default browser and nothing was being hit(I even tried attaching to a process).我将 firefox 作为我的默认浏览器,并且没有被击中(我什至尝试附加到进程)。 What finally worked for me was setting IE as the default.最终对我有用的是将 IE 设置为默认值。

Silverlight break points are now being hit for me: :) Silverlight 断点现在正在为我命中::)

Right Click on Web.UI project in solution.右键单击解决方案中的 Web.UI 项目。 go to Web, check Debuggers --> Silverlight save and Debug.. Make sure you have silverlight developer installed. go 到 Web,检查 Debuggers --> Silverlight 保存和调试。确保您已安装 Z9526E055C9CFD57BECF4 developer.590C9CFD57BECF44FA

Your code may be part of a class marked with the System.Diagnostics.DebuggerStepThroughAttribute .您的代码可能是标有System.Diagnostics.DebuggerStepThroughAttribute的 class 的一部分。 This happens with auto generated classes (like with Add Service Reference).这发生在自动生成的类中(如添加服务引用)。 If you are extending a partial class, other parts of the class definition may have that attribute.如果要扩展部分 class,则 class 定义的其他部分可能具有该属性。

Try unckecking the Options / Debugging / General / Enable Just My Code checkbox.尝试取消选中Options / Debugging / General / Enable Just My Code复选框。

Otherwise put your mouse over the red dot in the source code window, which becomes an empty circle if the debugger disabled it, a tooltip will give you additional information.否则将鼠标放在源代码 window 中的红点上,如果调试器禁用它,它将变成一个空圆圈,工具提示将为您提供更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM