[ 
https://issues.apache.org/jira/browse/LOG4NET-247?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rob Woerner updated LOG4NET-247:
--------------------------------

    Description: 
I have an application that registers for 
AppDomain.CurrentDomain.UnhandledException and Application.ThreadException.  
The handlers weren't getting triggered when exceptions occurred.  I have 
narrowed it down to this statement:

log4net.GlobalContext.Properties["RFN"] = "myfile.log";

If I take this statement out, exceptions trigger the global exception 
handler(s) as expected.  After debugging through the code, I see absolutely 
nothing that might cause this problem.  The Properties property is never even 
looked at again.  This behavior is bizarre and really interferes with 
debugging.  It doesn't seem to occur on all systems.

I have created a default WinForms app that does nothing except call the 
statement above and generate an exception.  If anyone has any idea what might 
cause this, I'd love to hear it.  Sample code below. All files not given here 
are the default files generated by the compiler.

----------- CrashTest.csproj ----------------------
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{0F520198-7D51-400A-A373-821F35462CC4}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>CrashTest</RootNamespace>
    <AssemblyName>CrashTest</AssemblyName>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' 
">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, 
PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>.\log4net.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Xml.Linq">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data.DataSetExtensions">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Form1.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="Form1.Designer.cs">
      <DependentUpon>Form1.cs</DependentUpon>
    </Compile>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <EmbeddedResource Include="Form1.resx">
      <DependentUpon>Form1.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets 
below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
--------------- Program.cs ---------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace CrashTest
{
        static class Program
        {
                /// <summary>
                /// The main entry point for the application.
                /// </summary>
                [STAThread]
                static void Main()
                {
                        
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                        AppDomain.CurrentDomain.UnhandledException += new 
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                        Application.ThreadException += new 
System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new Form1());
                }
                static void CurrentDomain_UnhandledException(object sender, 
UnhandledExceptionEventArgs e)
                {
                        MessageBox.Show("Crash One!");
                }

                static void Application_ThreadException(object sender, 
System.Threading.ThreadExceptionEventArgs e)
                {
                        MessageBox.Show("Crash Two!");
                }
        }
}
----------------- Form1.cs --------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CrashTest
{
        public partial class Form1 : Form
        {
                public Form1()
                {
                        log4net.GlobalContext.Properties["RFN"] = "foo";

                        InitializeComponent();
                }

                private void button1_Click(object sender, EventArgs e)
                {
                        StartCrash();
                }
                void StartCrash()
                {
                        System.Threading.Thread t = new 
System.Threading.Thread(EndCrash);
                        t.IsBackground = true;
                        t.Start();
                }
                void EndCrash()
                {
                        string s = null;
                        s.Clone();
                }
        }
}
-------------- Form1.Designer.cs -------------------------------
namespace CrashTest
{
        partial class Form1
        {
                /// <summary>
                /// Required designer variable.
                /// </summary>
                private System.ComponentModel.IContainer components = null;

                /// <summary>
                /// Clean up any resources being used.
                /// </summary>
                /// <param name="disposing">true if managed resources should be 
disposed; otherwise, false.</param>
                protected override void Dispose(bool disposing)
                {
                        if (disposing && (components != null))
                        {
                                components.Dispose();
                        }
                        base.Dispose(disposing);
                }

                #region Windows Form Designer generated code

                /// <summary>
                /// Required method for Designer support - do not modify
                /// the contents of this method with the code editor.
                /// </summary>
                private void InitializeComponent()
                {
                        this.button1 = new System.Windows.Forms.Button();
                        this.SuspendLayout();
                        // 
                        // button1
                        // 
                        this.button1.Location = new System.Drawing.Point(105, 
99);
                        this.button1.Name = "button1";
                        this.button1.Size = new System.Drawing.Size(75, 35);
                        this.button1.TabIndex = 0;
                        this.button1.Text = "Crash!";
                        this.button1.UseVisualStyleBackColor = true;
                        this.button1.Click += new 
System.EventHandler(this.button1_Click);
                        // 
                        // Form1
                        // 
                        this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 
16F);
                        this.AutoScaleMode = 
System.Windows.Forms.AutoScaleMode.Font;
                        this.ClientSize = new System.Drawing.Size(292, 260);
                        this.Controls.Add(this.button1);
                        this.Name = "Form1";
                        this.Text = "Form1";
                        this.ResumeLayout(false);

                }

                #endregion

                private System.Windows.Forms.Button button1;
        }
}





  was:
I have an application that registers for 
AppDomain.CurrentDomain.UnhandledException and Application.ThreadException.  
The handlers weren't getting triggered when exceptions occurred.  I have 
narrowed it down to this statement:

log4net.GlobalContext.Properties["RFN"] = "myfile.log";

If I take this statement out, exceptions trigger the global exception 
handler(s) as expected.  After debugging through the code, I see absolutely 
nothing that might cause this problem.  The Properties property is never even 
looked at again.  This behavior is bizarre and really interferes with 
debugging.  It doesn't seem to occur on all systems.

I have created a default WinForms app that does not except call the statement 
above and generate an exception.  If anyone has any idea what might cause this, 
I'd love to here it.  Sample code below. All files not given here are the 
default files generated by the compiler.

----------- CrashTest.csproj ----------------------
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{0F520198-7D51-400A-A373-821F35462CC4}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>CrashTest</RootNamespace>
    <AssemblyName>CrashTest</AssemblyName>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' 
">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, 
PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>.\log4net.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Xml.Linq">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data.DataSetExtensions">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Form1.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="Form1.Designer.cs">
      <DependentUpon>Form1.cs</DependentUpon>
    </Compile>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <EmbeddedResource Include="Form1.resx">
      <DependentUpon>Form1.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets 
below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
--------------- Program.cs ---------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace CrashTest
{
        static class Program
        {
                /// <summary>
                /// The main entry point for the application.
                /// </summary>
                [STAThread]
                static void Main()
                {
                        
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                        AppDomain.CurrentDomain.UnhandledException += new 
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                        Application.ThreadException += new 
System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new Form1());
                }
                static void CurrentDomain_UnhandledException(object sender, 
UnhandledExceptionEventArgs e)
                {
                        MessageBox.Show("Crash One!");
                }

                static void Application_ThreadException(object sender, 
System.Threading.ThreadExceptionEventArgs e)
                {
                        MessageBox.Show("Crash Two!");
                }
        }
}
----------------- Form1.cs --------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CrashTest
{
        public partial class Form1 : Form
        {
                public Form1()
                {
                        log4net.GlobalContext.Properties["RFN"] = "foo";

                        InitializeComponent();
                }

                private void button1_Click(object sender, EventArgs e)
                {
                        StartCrash();
                }
                void StartCrash()
                {
                        System.Threading.Thread t = new 
System.Threading.Thread(EndCrash);
                        t.IsBackground = true;
                        t.Start();
                }
                void EndCrash()
                {
                        string s = null;
                        s.Clone();
                }
        }
}
-------------- Form1.Designer.cs -------------------------------
namespace CrashTest
{
        partial class Form1
        {
                /// <summary>
                /// Required designer variable.
                /// </summary>
                private System.ComponentModel.IContainer components = null;

                /// <summary>
                /// Clean up any resources being used.
                /// </summary>
                /// <param name="disposing">true if managed resources should be 
disposed; otherwise, false.</param>
                protected override void Dispose(bool disposing)
                {
                        if (disposing && (components != null))
                        {
                                components.Dispose();
                        }
                        base.Dispose(disposing);
                }

                #region Windows Form Designer generated code

                /// <summary>
                /// Required method for Designer support - do not modify
                /// the contents of this method with the code editor.
                /// </summary>
                private void InitializeComponent()
                {
                        this.button1 = new System.Windows.Forms.Button();
                        this.SuspendLayout();
                        // 
                        // button1
                        // 
                        this.button1.Location = new System.Drawing.Point(105, 
99);
                        this.button1.Name = "button1";
                        this.button1.Size = new System.Drawing.Size(75, 35);
                        this.button1.TabIndex = 0;
                        this.button1.Text = "Crash!";
                        this.button1.UseVisualStyleBackColor = true;
                        this.button1.Click += new 
System.EventHandler(this.button1_Click);
                        // 
                        // Form1
                        // 
                        this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 
16F);
                        this.AutoScaleMode = 
System.Windows.Forms.AutoScaleMode.Font;
                        this.ClientSize = new System.Drawing.Size(292, 260);
                        this.Controls.Add(this.button1);
                        this.Name = "Form1";
                        this.Text = "Form1";
                        this.ResumeLayout(false);

                }

                #endregion

                private System.Windows.Forms.Button button1;
        }
}






> Adding to log4net.GlobalContext.Properties causes UnhandledException filter 
> to fail.
> ------------------------------------------------------------------------------------
>
>                 Key: LOG4NET-247
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-247
>             Project: Log4net
>          Issue Type: Bug
>    Affects Versions: 1.2.10
>         Environment: Windows XP, SP2.
>            Reporter: Rob Woerner
>            Priority: Blocker
>             Fix For: v.Next
>
>
> I have an application that registers for 
> AppDomain.CurrentDomain.UnhandledException and Application.ThreadException.  
> The handlers weren't getting triggered when exceptions occurred.  I have 
> narrowed it down to this statement:
> log4net.GlobalContext.Properties["RFN"] = "myfile.log";
> If I take this statement out, exceptions trigger the global exception 
> handler(s) as expected.  After debugging through the code, I see absolutely 
> nothing that might cause this problem.  The Properties property is never even 
> looked at again.  This behavior is bizarre and really interferes with 
> debugging.  It doesn't seem to occur on all systems.
> I have created a default WinForms app that does nothing except call the 
> statement above and generate an exception.  If anyone has any idea what might 
> cause this, I'd love to hear it.  Sample code below. All files not given here 
> are the default files generated by the compiler.
> ----------- CrashTest.csproj ----------------------
> <?xml version="1.0" encoding="utf-8"?>
> <Project ToolsVersion="3.5" DefaultTargets="Build" 
> xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
>   <PropertyGroup>
>     <Configuration Condition=" '$(Configuration)' == '' 
> ">Debug</Configuration>
>     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
>     <ProductVersion>9.0.30729</ProductVersion>
>     <SchemaVersion>2.0</SchemaVersion>
>     <ProjectGuid>{0F520198-7D51-400A-A373-821F35462CC4}</ProjectGuid>
>     <OutputType>WinExe</OutputType>
>     <AppDesignerFolder>Properties</AppDesignerFolder>
>     <RootNamespace>CrashTest</RootNamespace>
>     <AssemblyName>CrashTest</AssemblyName>
>     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
>     <FileAlignment>512</FileAlignment>
>   </PropertyGroup>
>   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' 
> ">
>     <DebugSymbols>true</DebugSymbols>
>     <DebugType>full</DebugType>
>     <Optimize>false</Optimize>
>     <OutputPath>bin\Debug\</OutputPath>
>     <DefineConstants>DEBUG;TRACE</DefineConstants>
>     <ErrorReport>prompt</ErrorReport>
>     <WarningLevel>4</WarningLevel>
>   </PropertyGroup>
>   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 
> 'Release|AnyCPU' ">
>     <DebugType>pdbonly</DebugType>
>     <Optimize>true</Optimize>
>     <OutputPath>bin\Release\</OutputPath>
>     <DefineConstants>TRACE</DefineConstants>
>     <ErrorReport>prompt</ErrorReport>
>     <WarningLevel>4</WarningLevel>
>   </PropertyGroup>
>   <ItemGroup>
>     <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, 
> PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
>       <SpecificVersion>False</SpecificVersion>
>       <HintPath>.\log4net.dll</HintPath>
>     </Reference>
>     <Reference Include="System" />
>     <Reference Include="System.Core">
>       <RequiredTargetFramework>3.5</RequiredTargetFramework>
>     </Reference>
>     <Reference Include="System.Xml.Linq">
>       <RequiredTargetFramework>3.5</RequiredTargetFramework>
>     </Reference>
>     <Reference Include="System.Data.DataSetExtensions">
>       <RequiredTargetFramework>3.5</RequiredTargetFramework>
>     </Reference>
>     <Reference Include="System.Data" />
>     <Reference Include="System.Deployment" />
>     <Reference Include="System.Drawing" />
>     <Reference Include="System.Windows.Forms" />
>     <Reference Include="System.Xml" />
>   </ItemGroup>
>   <ItemGroup>
>     <Compile Include="Form1.cs">
>       <SubType>Form</SubType>
>     </Compile>
>     <Compile Include="Form1.Designer.cs">
>       <DependentUpon>Form1.cs</DependentUpon>
>     </Compile>
>     <Compile Include="Program.cs" />
>     <Compile Include="Properties\AssemblyInfo.cs" />
>     <EmbeddedResource Include="Form1.resx">
>       <DependentUpon>Form1.cs</DependentUpon>
>     </EmbeddedResource>
>     <EmbeddedResource Include="Properties\Resources.resx">
>       <Generator>ResXFileCodeGenerator</Generator>
>       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
>       <SubType>Designer</SubType>
>     </EmbeddedResource>
>     <Compile Include="Properties\Resources.Designer.cs">
>       <AutoGen>True</AutoGen>
>       <DependentUpon>Resources.resx</DependentUpon>
>     </Compile>
>     <None Include="Properties\Settings.settings">
>       <Generator>SettingsSingleFileGenerator</Generator>
>       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
>     </None>
>     <Compile Include="Properties\Settings.Designer.cs">
>       <AutoGen>True</AutoGen>
>       <DependentUpon>Settings.settings</DependentUpon>
>       <DesignTimeSharedInput>True</DesignTimeSharedInput>
>     </Compile>
>   </ItemGroup>
>   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
>   <!-- To modify your build process, add your task inside one of the targets 
> below and uncomment it. 
>        Other similar extension points exist, see Microsoft.Common.targets.
>   <Target Name="BeforeBuild">
>   </Target>
>   <Target Name="AfterBuild">
>   </Target>
>   -->
> </Project>
> --------------- Program.cs ---------------------------
> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Windows.Forms;
> namespace CrashTest
> {
>       static class Program
>       {
>               /// <summary>
>               /// The main entry point for the application.
>               /// </summary>
>               [STAThread]
>               static void Main()
>               {
>                       
> Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
>                       AppDomain.CurrentDomain.UnhandledException += new 
> UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
>                       Application.ThreadException += new 
> System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
>                       Application.EnableVisualStyles();
>                       Application.SetCompatibleTextRenderingDefault(false);
>                       Application.Run(new Form1());
>               }
>               static void CurrentDomain_UnhandledException(object sender, 
> UnhandledExceptionEventArgs e)
>               {
>                       MessageBox.Show("Crash One!");
>               }
>               static void Application_ThreadException(object sender, 
> System.Threading.ThreadExceptionEventArgs e)
>               {
>                       MessageBox.Show("Crash Two!");
>               }
>       }
> }
> ----------------- Form1.cs --------------------
> using System;
> using System.Collections.Generic;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Linq;
> using System.Text;
> using System.Windows.Forms;
> namespace CrashTest
> {
>       public partial class Form1 : Form
>       {
>               public Form1()
>               {
>                       log4net.GlobalContext.Properties["RFN"] = "foo";
>                       InitializeComponent();
>               }
>               private void button1_Click(object sender, EventArgs e)
>               {
>                       StartCrash();
>               }
>               void StartCrash()
>               {
>                       System.Threading.Thread t = new 
> System.Threading.Thread(EndCrash);
>                       t.IsBackground = true;
>                       t.Start();
>               }
>               void EndCrash()
>               {
>                       string s = null;
>                       s.Clone();
>               }
>       }
> }
> -------------- Form1.Designer.cs -------------------------------
> namespace CrashTest
> {
>       partial class Form1
>       {
>               /// <summary>
>               /// Required designer variable.
>               /// </summary>
>               private System.ComponentModel.IContainer components = null;
>               /// <summary>
>               /// Clean up any resources being used.
>               /// </summary>
>               /// <param name="disposing">true if managed resources should be 
> disposed; otherwise, false.</param>
>               protected override void Dispose(bool disposing)
>               {
>                       if (disposing && (components != null))
>                       {
>                               components.Dispose();
>                       }
>                       base.Dispose(disposing);
>               }
>               #region Windows Form Designer generated code
>               /// <summary>
>               /// Required method for Designer support - do not modify
>               /// the contents of this method with the code editor.
>               /// </summary>
>               private void InitializeComponent()
>               {
>                       this.button1 = new System.Windows.Forms.Button();
>                       this.SuspendLayout();
>                       // 
>                       // button1
>                       // 
>                       this.button1.Location = new System.Drawing.Point(105, 
> 99);
>                       this.button1.Name = "button1";
>                       this.button1.Size = new System.Drawing.Size(75, 35);
>                       this.button1.TabIndex = 0;
>                       this.button1.Text = "Crash!";
>                       this.button1.UseVisualStyleBackColor = true;
>                       this.button1.Click += new 
> System.EventHandler(this.button1_Click);
>                       // 
>                       // Form1
>                       // 
>                       this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 
> 16F);
>                       this.AutoScaleMode = 
> System.Windows.Forms.AutoScaleMode.Font;
>                       this.ClientSize = new System.Drawing.Size(292, 260);
>                       this.Controls.Add(this.button1);
>                       this.Name = "Form1";
>                       this.Text = "Form1";
>                       this.ResumeLayout(false);
>               }
>               #endregion
>               private System.Windows.Forms.Button button1;
>       }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to