Try / Catch throws no exception
I have a project with FiddlerApplication
that saves some sessions for me. When I run the first run of the program after restarting it 100% fails and then 10% fails 90%.
The biggest problem when it fails is not throwing any exceptions in try / catch. Here is my code
static class Program
{
[STAThread]
static void Main(string[] args)
{
try
{
browserToRun.GoTo("www.test.com");
FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
//HERE it fails
FiddlerApplication.Startup(8888, true, true, true);
FiddlerApplication.Shutdown();
}
catch (Exception ex)
{
// it is not getting to here
FiddlerApplication.AfterSessionComplete -= FiddlerApplication_AfterSessionComplete;
FiddlerApplication.Shutdown();
}
}
public static void FiddlerApplication_AfterSessionComplete(Session sess)
{
try
{
if (!sess.fullUrl.Contains("test"))
return;
GlobalDownloadLink = sess.fullUrl;
}
catch (Exception ex)
{
successful = false;
throw new System.ArgumentException(ex.Message, "FiddlerApplication_AfterSessionComplete");
}
}
}
My new updated Apconfigwith new error Configuration system failed to initialize
<configuration>
<runtime>
<legacyCorruptedStateExceptionsPolicy enabled="true" />
</runtime>
<configSections>
</configSections>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
<appSettings>
<add key="BrowserShow" value="Y"/>
<add key="DebugCreate" value="true"/>
<add key="FileName10" value="AccountActivity"/>
<add key="FileName20" value="ForeignActivities"/>
<add key="FileNameShar" value="MatbeotSchirim"/>
</appSettings>
</configuration>
source to share
One problem with your code is that you are throwing System.ArgumentException
out of the background thread on which sessions are being processed; such exceptions will not be caught by an exception handler in your main thread.
Also, the way your code is written right now is simply wrong; calling Startup
and then immediately calling Shutdown
will bring nothing.
source to share