Skip to content

Commit d6810b3

Browse files
authored
add missing code snippets (#11075)
1 parent 17a1a93 commit d6810b3

File tree

5 files changed

+82
-72
lines changed

5 files changed

+82
-72
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1"/></startup></configuration>

snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/cs.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
22
<PropertyGroup>
33
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
44
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,6 +9,8 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>CS</RootNamespace>
1111
<AssemblyName>CS</AssemblyName>
12+
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
13+
<TargetFrameworkProfile />
1214
</PropertyGroup>
1315
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1416
<DebugSymbols>true</DebugSymbols>
@@ -18,6 +20,7 @@
1820
<DefineConstants>DEBUG;TRACE</DefineConstants>
1921
<ErrorReport>prompt</ErrorReport>
2022
<WarningLevel>4</WarningLevel>
23+
<Prefer32Bit>false</Prefer32Bit>
2124
</PropertyGroup>
2225
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2326
<DebugType>pdbonly</DebugType>
@@ -26,6 +29,7 @@
2629
<DefineConstants>TRACE</DefineConstants>
2730
<ErrorReport>prompt</ErrorReport>
2831
<WarningLevel>4</WarningLevel>
32+
<Prefer32Bit>false</Prefer32Bit>
2933
</PropertyGroup>
3034
<ItemGroup>
3135
<Reference Include="System" />
@@ -41,6 +45,9 @@
4145
<ItemGroup>
4246
<Folder Include="Properties\" />
4347
</ItemGroup>
48+
<ItemGroup>
49+
<None Include="app.config" />
50+
</ItemGroup>
4451
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4552
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
4653
Other similar extension points exist, see Microsoft.Common.targets.

snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/makefile

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
// Snippet for S_UE System.ServiceModel.Dispatcher.ExceptionHandler.HandleException
22
// 06192006 Created by A.Hu
33

4-
// <snippet0>
4+
// <Snippet0>
55
using System;
66
using System.ServiceModel.Dispatcher;
77

88
namespace CS
99
{
10-
public class MyExceptionHandler: ExceptionHandler
10+
public class MyExceptionHandler : ExceptionHandler
1111
{
12-
// HandleException method override gives control to
13-
// your code.
14-
public override bool HandleException ( Exception ex )
15-
{
16-
// This method contains logic to decide whether
17-
// the exception is serious enough
18-
// to terminate the process.
19-
return ShouldTerminateProcess (ex);
20-
}
12+
// HandleException method override gives control to
13+
// your code.
14+
public override bool HandleException(Exception ex)
15+
{
16+
// This method contains logic to decide whether
17+
// the exception is serious enough
18+
// to terminate the process.
19+
return ShouldTerminateProcess(ex);
20+
}
2121

22-
public bool ShouldTerminateProcess (Exception ex)
23-
{
24-
// Write your logic here.
25-
return true;
26-
}
22+
public bool ShouldTerminateProcess(Exception ex)
23+
{
24+
// Write your logic here.
25+
return true;
26+
}
2727
}
28+
// </Snippet0>
2829

29-
// </snippet0>
3030
class Program
3131
{
32-
// <snippet1>
33-
static void Main(string[] args)
32+
static void Main()
3433
{
34+
// <Snippet1>
3535
// Create an instance of the MyExceptionHandler class.
3636
MyExceptionHandler thisExceptionHandler =
3737
new MyExceptionHandler();
@@ -43,8 +43,9 @@ static void Main(string[] args)
4343
thisExceptionHandler;
4444

4545
// After the handler is set, write your call to
46-
// System.ServiceModel.ICommunication.Open here
46+
// System.ServiceModel.ICommunication.Open here.
47+
48+
// </Snippet1>
4749
}
4850
}
49-
// </snippet1>
5051
}

xml/System.ServiceModel.Dispatcher/ExceptionHandler.xml

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@
1717
<Docs>
1818
<summary>Extend the <see cref="T:System.ServiceModel.Dispatcher.ExceptionHandler" /> class to create an exception handler for unhandled exceptions that occur within the Windows Communication Foundation (WCF) runtime.</summary>
1919
<remarks>
20-
<format type="text/markdown"><![CDATA[
21-
22-
## Remarks
23-
Extend the <xref:System.ServiceModel.Dispatcher.ExceptionHandler> class and override the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> method to determine whether an exception should terminate the application. Then create a new instance of your custom <xref:System.ServiceModel.Dispatcher.ExceptionHandler> class and assign it to the static <xref:System.ServiceModel.Dispatcher.ExceptionHandler.AsynchronousThreadExceptionHandler%2A> or <xref:System.ServiceModel.Dispatcher.ExceptionHandler.TransportExceptionHandler%2A> property prior to creating WCF clients or services.
24-
25-
26-
27-
## Examples
28-
The following code example shows an implementation of the <xref:System.ServiceModel.Dispatcher.ExceptionHandler> abstract class that overrides the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> method.
29-
20+
<format type="text/markdown"><![CDATA[
21+
22+
## Remarks
23+
24+
Extend the <xref:System.ServiceModel.Dispatcher.ExceptionHandler> class and override the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> method to determine whether an exception should terminate the application. Then create a new instance of your custom <xref:System.ServiceModel.Dispatcher.ExceptionHandler> class and assign it to the static <xref:System.ServiceModel.Dispatcher.ExceptionHandler.AsynchronousThreadExceptionHandler%2A> or <xref:System.ServiceModel.Dispatcher.ExceptionHandler.TransportExceptionHandler%2A> property prior to creating WCF clients or services.
25+
26+
## Examples
27+
28+
The following code example shows an implementation of the <xref:System.ServiceModel.Dispatcher.ExceptionHandler> abstract class that overrides the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> method.
29+
3030
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/program.cs" id="Snippet0":::
31-
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet0":::
32-
33-
The following code example shows how to enable the custom `MyExceptionHandler` for unhandled exceptions that occur within the WCF runtime.
34-
31+
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet0":::
32+
33+
The following code example shows how to enable the custom `MyExceptionHandler` for unhandled exceptions that occur within the WCF runtime.
34+
3535
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/program.cs" id="Snippet1":::
36-
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet1":::
37-
36+
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet1":::
37+
3838
]]></format>
3939
</remarks>
4040
</Docs>
@@ -137,13 +137,13 @@
137137
<summary>Gets or sets the current <see cref="T:System.ServiceModel.Dispatcher.ExceptionHandler" /> implementation for the application domain.</summary>
138138
<value>Assign a custom <see cref="T:System.ServiceModel.Dispatcher.ExceptionHandler" /> object that receives unhandled exceptions that occur on asynchronous Windows Communication Foundation (WCF) threads.</value>
139139
<remarks>
140-
<format type="text/markdown"><![CDATA[
141-
142-
## Remarks
143-
By default, the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.AsynchronousThreadExceptionHandler%2A> property is `null`, and unhandled exceptions on asynchronous WCF threads terminate the application. Set this property to an <xref:System.ServiceModel.Dispatcher.ExceptionHandler> object to receive and react to these exceptions.
144-
145-
If an unhandled exception occurs on an asynchronous WCF thread and reaches this handler, the state of the application domain may be compromised. <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> should not return `true` for these exceptions.
146-
140+
<format type="text/markdown"><![CDATA[
141+
142+
## Remarks
143+
By default, the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.AsynchronousThreadExceptionHandler%2A> property is `null`, and unhandled exceptions on asynchronous WCF threads terminate the application. Set this property to an <xref:System.ServiceModel.Dispatcher.ExceptionHandler> object to receive and react to these exceptions.
144+
145+
If an unhandled exception occurs on an asynchronous WCF thread and reaches this handler, the state of the application domain may be compromised. <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> should not return `true` for these exceptions.
146+
147147
]]></format>
148148
</remarks>
149149
</Docs>
@@ -168,27 +168,28 @@
168168
<Parameter Name="exception" Type="System.Exception" />
169169
</Parameters>
170170
<Docs>
171-
<param name="exception">The exception the occurred within the Windows Communication Foundation (WCF) runtime and which may terminate the application.</param>
171+
<param name="exception">The exception that occurred within the Windows Communication Foundation (WCF) runtime and which might terminate the application.</param>
172172
<summary>When overridden in a derived class, returns <see langword="true" /> if the exception has been handled, or <see langword="false" /> if the exception should be rethrown and the application terminated.</summary>
173173
<returns>
174174
<see langword="true" /> if the exception has been handled; otherwise, <see langword="false" />.</returns>
175175
<remarks>
176-
<format type="text/markdown"><![CDATA[
177-
178-
## Remarks
179-
The <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> property returns `true` if the exception has been handled. If it returns `false` or throws a different exception, the original exception is rethrown.
180-
181-
182-
183-
## Examples
184-
The following code example shows an implementation of the <xref:System.ServiceModel.Dispatcher.ExceptionHandler> abstract class that overrides the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> method.
185-
186-
187-
188-
The following code example shows how to enable the custom `MyExceptionHandler` for unhandled exceptions that occur within the WCF runtime.
189-
190-
191-
176+
<format type="text/markdown"><![CDATA[
177+
178+
## Remarks
179+
The <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> property returns `true` if the exception has been handled. If it returns `false` or throws a different exception, the original exception is rethrown.
180+
181+
## Examples
182+
183+
The following code example shows an implementation of the <xref:System.ServiceModel.Dispatcher.ExceptionHandler> abstract class that overrides the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> method.
184+
185+
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/program.cs" id="Snippet0":::
186+
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet0":::
187+
188+
The following code example shows how to enable the custom `MyExceptionHandler` for unhandled exceptions that occur within the WCF runtime.
189+
190+
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/program.cs" id="Snippet1":::
191+
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet1":::
192+
192193
]]></format>
193194
</remarks>
194195
</Docs>
@@ -223,13 +224,14 @@
223224
<summary>Gets or sets the current transport <see cref="T:System.ServiceModel.Dispatcher.ExceptionHandler" /> implementation for the application domain.</summary>
224225
<value>A custom <see cref="T:System.ServiceModel.Dispatcher.ExceptionHandler" /> object that receives unhandled exceptions that occur within the global Windows Communication Foundation (WCF) transports.</value>
225226
<remarks>
226-
<format type="text/markdown"><![CDATA[
227-
228-
## Remarks
229-
By default, the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.TransportExceptionHandler%2A> property is set to the value of <xref:System.ServiceModel.Dispatcher.ExceptionHandler.AlwaysHandle%2A>, causing unhandled exceptions within WCF transports to be ignored. Set this property to an instance of <xref:System.ServiceModel.Dispatcher.ExceptionHandler> to receive and react to these exceptions.
230-
231-
If an unhandled exception occurs within a global WCF transport and reaches this handler, there is a possibility that the state of the application domain is compromised. <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> can return `false` for these exceptions to cause the application to be terminated.
232-
227+
<format type="text/markdown"><![CDATA[
228+
229+
## Remarks
230+
231+
By default, the <xref:System.ServiceModel.Dispatcher.ExceptionHandler.TransportExceptionHandler%2A> property is set to the value of <xref:System.ServiceModel.Dispatcher.ExceptionHandler.AlwaysHandle%2A>, causing unhandled exceptions within WCF transports to be ignored. Set this property to an instance of <xref:System.ServiceModel.Dispatcher.ExceptionHandler> to receive and react to these exceptions.
232+
233+
If an unhandled exception occurs within a global WCF transport and reaches this handler, there is a possibility that the state of the application domain is compromised. <xref:System.ServiceModel.Dispatcher.ExceptionHandler.HandleException%2A> can return `false` for these exceptions to cause the application to be terminated.
234+
233235
]]></format>
234236
</remarks>
235237
</Docs>

0 commit comments

Comments
 (0)