【问题标题】:Set a Function Breakpoint on a C# Generic Class/Method in Visual Studio?在 Visual Studio 中的 C# 泛型类/方法上设置函数断点?
【发布时间】:2018-02-07 21:11:54
【问题描述】:

如何在泛型类/方法上设置Function Breakpoint

我可能正在尝试找出要使用的语法。这是我要设置的类/方法:-

namespace MyCustom.SpecialNS
{
  public class SomeGenericConditionClass<T> : BaseConditionNS.WhenCondition<T> where T : BaseRuleNS.RuleContext
  {

    protected override bool Execute(T ruleContextParam)
    {
        string hello = "Hello. Set Breakpoint here!";
        return true;
    }
  }
}

作为一个仅供参考,我正在尝试调试第三方 dll,其中我设置了其他方法来使用函数断点调试常规具体类/方法。 即我可以设置

MyCustom.SpecialNS.SimpleConcreteClass.BasicExecute(MyCustomAttrNS.MyAttributeType)

它会成功破解。 但是对于泛型,我不确定T类型是什么,或者正确设置Function Breakpoint的语法是什么,而且它是第三方DLL,所以我不能只打开代码并单击创建断点.

我试过了

MyCustom.SpecialNS.SomeGenericConditionClass.Execute

MyCustom.SpecialNS.SomeGenericConditionClass<T>.Execute<T>

以及它周围的许多其他变体,但我一无所获。

有什么想法吗?

【问题讨论】:

  • 你试过SomeGenericConditionClass&lt;T&gt;.Execute吗?我不确定这是否存在于第 3 方 DLL 中,但这适用于我编写的代码。
  • 嗯,我之前尝试过,但没有成功。我再测试一下。
  • 依次点击Debug、Windows、Breakpoints,点击New、Break at function,输入函数,点击OK。请确保您已关闭调试配置下的“仅启用我的代码”。
  • 是的,我知道很多。我在使用“输入函数”部分的语法。
  • @asherber 这正是我正在寻找的语法。不过,我对第 3 方 DLL 有一个奇怪的事情。我只需要触摸 Web.config 文件并再试一次(我试图用我试图调试的 DLL 实现的一个奇怪的副作用)。然后你给出的语法适用于断点。如果您愿意,请在此处添加该语法作为答案,我会认为它是正确的。谢谢!

标签: c# debugging generics visual-studio-2017 breakpoints


【解决方案1】:

SomeGenericConditionClass&lt;T&gt;.Execute 为我工作。 (从我上面的评论中提升。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-08
    • 2022-01-06
    • 1970-01-01
    • 1970-01-01
    • 2013-10-01
    • 2023-01-26
    相关资源
    最近更新 更多