![](/img/trans.png)
[英]Debugging Azure Service Fabric Application in Visual Studio for 5 node cluster
[英]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帖子中所读到的内容,实现起来似乎是不可能或非常麻烦的:
无论如何,我是否需要在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.