Visual Studio调试器破坏了错误的源代码 [英] Visual Studio debugger breaking in wrong source code

查看:87
本文介绍了Visual Studio调试器破坏了错误的源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个VB .NET项目为我们的产品构建外接程序.这两个项目的源文件具有相同的名称,甚至具有相同的功能,但是代码不同.我调用了debugger break API,这使我可以附加一个实例 VS 2012的过程.我在代码的各个位置设置了断点,然后继续运行.那些断点跳闸,如预期的那样.但是,在其他VB .NET项目的sourc文件中,调试器也会中断.所以看来调试器对 我为哪个源文件设置了断点.这不是主要问题,但肯定会造成混淆.


研发荷兰

I have a couple of VB .NET projects that build add-ins for our product. The two projects have source files with the same names and even with the same functions in them, but different code. I call the debugger break API and that lets me attach an instance of VS 2012 to the process. I set breakpoints in various places in the code and continue running. Those break points trip as expected. However in the other VB .NET projects' sourc files, the debugger also breaks. So it appears the debugger is confused as to which source file I have breakpoints set. Not a major issue but it sure can be confusing.


R.D. Holland

推荐答案

你好

一个想法(虽然可能不是正确的,但是它是合乎逻辑的)是混淆来自命名空间.一个示例,两个项目(无论是在相同的解决方案中还是作为已编译的程序集)在主项目中均具有引用,并且位于导入的名称空间"下, 可能导致歧义,或者代码模块,表单或类具有两个项目的导入语句.没关系,一种测试该理论的方法是在函数,过程或方法之前加上指向函数,过程的完整名称空间和路径. 或方法.

One thought (and it may not be correct but its logical) is the confusion lies from the namespaces. One example, both projects (be it in the same solution or as compiled assemblies) have references in the main project and are under 'Imported namespaces' which can lead to ambiguity or that a code module, form or class has import statements for both projects. No matter, one method to test this theory out is to precede the function, procedure or method with the full namespace and path leading to the function, procedure or methods.

因此,我们可能有两个类,两个类都名为DataOperations,并带有一个名为GetCustomers的方法.一个在名为DataAccess1的项目中,另一个在一个DataAccess2中.您可能会写  

So we might have a two classes, both named DataOperations with a method named GetCustomers. One is in a project named DataAccess1 while the other DataAccess2. You might write   

Dim da as New DataOperaions
da.GetCustomers()

当下面的内容很清晰时,就碰到当前的问题

And run into the current issue while the following is crystal clear

Dim da as New DataAccess1.DataOperaions
da.GetCustomers()

因此,如前所述,这是有根据的猜测,可能不适用于此处,但值得研究

So as mentioned up front this is an educated guess and may not apply here but worth investigating


这篇关于Visual Studio调试器破坏了错误的源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆