This is not a valid location for a breakpoint

后端 未结 4 2235
梦毁少年i
梦毁少年i 2021-02-13 03:44

I am trying to put a breakpoint on below mentioned page in my ASP.Net MVC 2 application\'s .ascx or .aspx files in Visual Studio 2010. But it won\'t let me, it shows:

相关标签:
4条回答
  • 2021-02-13 04:09

    This problem will happen if you are using Asp.Net Mvc 5 in Visual Studio 2012, but have not installed the proper tooling. For me, this happened because I upgraded my version of Asp.Net Mvc 4 to version 5 via Nuget. However, this did not install the tooling in VS 2012 so that the IDE can properly parse and handle the .cshtml files. Thus none of the razor code showed up as valid C#, and it was impossible to set any breakpoints (with the error "this is not a valid location for a breakpoint" if you try to set it).

    The solution is to install the proper tooling. (or direct link) Once I installed the tooling and restarted VS, I was able to happily set breakpoints in .cshtml files once more.

    0 讨论(0)
  • 2021-02-13 04:17

    This is a bug in Visual Studio 2013. It should be fixed in update 2 (or higher).
    That said, updating only temporarily solved the problem for myself.

    0 讨论(0)
  • 2021-02-13 04:18

    After showed the syntax highlighting issue by @Keith I went through my file top to bottom and vice-verse. Then I have found the issue.

    There was a warning message on my project as I showed on EDIT 4 above.

    After I solved that issue, Brake point (debug) issue also vanished.

    For that I have used below mentioned Link.

    Could not load file or assembly 'msshrtmi' - incorrect format in Azure deployment

    In future I will write a complete step by step guide to show how to get rid-off this issue.

    Thanks for every one who gave me a support.

    0 讨论(0)
  • 2021-02-13 04:19

    Looking at the content of the <% %> code block in your screenshot shows that the syntax is not highlighted. Usually this means that VS has not recognised that the block contains server side C# code.

    It works for Javascript because VS can recognise that as client side script and break on it.

    Fix the syntax highlighting and you'll be able to break on it too.

    Typically this happens because VS has a tough job switching between HTML editing (with visual preview, of a sort) and C# code and occasionally gets it wrong.

    The commonest cause of this is a missing Language directive at the top of the .aspx or .ascx file:

    <%@ Page Language="C#" ...
    

    Or

    <%@ Control Language="C#" ...
    

    You can also try an explicit code block, something like:

    <script type="text/C#" runat="server"> ...
    

    This can also be caused by nested .master pages: try clearing the ReflectedSchemas folder: %appdata%\Microsoft\VisualStudio\10.0\ReflectedSchemas\

    Removing the ReSharper trial has also been known to cause this.

    Finally, sometimes it's just confusion on VS's part - try restarting, and if that doesn't work try reorganising the file and restarting again. Stupid (I know) but sometimes that prompts VS to figure it out.

    Incidentally this is something they've significantly improved in VS 2012

    0 讨论(0)
提交回复
热议问题