簡體   English   中英

Service Broker /外部應用程序激活和Visual Studio調試

[英]Service Broker / External Application Activation and Visual Studio Debugging

我剛剛轉到使用很多Service Broker功能的代碼庫。

我的EAService.config設置如下

<ApplicationService name="NotificationTest" enabled="true">
  <OnNotification>
    <ServerName>MyServer\MyInstance</ServerName>
    <DatabaseName>MyDatabase</DatabaseName>
    <SchemaName>dbo</SchemaName>
    <QueueName>MyQueueName</QueueName>
  </OnNotification>
  <LaunchInfo>
    <ImagePath>C:\SomeFolder\SomeConsoleApp.exe</ImagePath>
    <CmdLineArgs>myCommandLineArg1</CmdLineArgs>
    <WorkDir>C:\SomeFolder\</WorkDir>
  </LaunchInfo>
  <Concurrency min="1" max="1" />
</ApplicationService>   

我嘗試調試上述代碼時遇到了問題。

由於Service Broker外部激活程序(C:\\ Program Files \\ Service Broker \\ External Activator \\ Bin \\ ssbeas.exe)實例化了代碼。...據我所知,這不是我可以在“調試”中運行的東西。模式”以等待呼叫進入並設置斷點。

例如,對於一個WEBAPI項目,我可以執行傳統的Start / Debug,並在ApiController / Method上放置一個斷點,當一個請求進入時,它會在該斷點處中斷,我可以從那里進行調試。 。

使用Service Broker,它正在實例化某些.exe ....,並且.exe​​可能會如此快速地打開和關閉,而我無法“搜索並找到”將調試器附加到該文件。

我還以為“也許我會讓Service Broker將消息發送到WCF服務”,但是根據我在此SOF帖子中所讀到的內容,實現起來似乎是不可能或非常麻煩的:

Service Broker和WCF的互操作性

無論如何,我是否需要在EAService.config中進行上述設置,並使調試器中斷,如下圖所示?

還是有人發現了一種非hacky的方式來調試由Service Broker“激活”的C#代碼?

簡單控制台應用程序

您有幾種選擇:

A.修改EAConfig以在調試器下啟動程序:

  <ImagePath>C:\PathToDebugger\YourDebuggerOfChoice.exe</ImagePath>
  <CmdLineArgs>C:\SomeFolder\SomeConsoleApp.exe myCommandLineArg1</CmdLineArgs>

B.使用GFlags映像執行選項將調試器添加到您的應用程序
C.使用Debugger.Launch()從應用程序本身啟動調試Debugger.Launch()
D.禁用EA並直接從VS(F5)運行應用程序以進行調試,然后啟用EA。

因此,這就是我最終找到的……這是我能找到的最一致的方法。

    static void Main(string[] args)
    {

        try
        {

#if DEBUG
            int index = Array.FindIndex(args, x => x.Equals("LAUNCHDEBUGGER", StringComparison.OrdinalIgnoreCase));
            if (index > -1)
            {
                System.Diagnostics.Debugger.Launch();
            }
#endif

 <LaunchInfo>
    <ImagePath>C:\SomeFolder\SomeConsoleApp.exe</ImagePath>
    <CmdLineArgs>myCommandLineArg1 LAUNCHDEBUGGER</CmdLineArgs>
    <WorkDir>C:\SomeFolder\</WorkDir>
  </LaunchInfo>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM