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>

      

+3


source to share


3 answers


Some exceptions don't get caught in try_catch blocks unless you specify a [HandleProcessCorruptedStateExceptions]

function attribute ( Main

in your code). Alternatively, this can be accomplished by modifying the configuration file described in Oxoron.



+4


source


Try adding <runtime> <legacyCorruptedStateExceptionsPolicy enabled="true" /> </runtime>



to the config file. Source here .

+3


source


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.

0


source







All Articles