Skip to content

[UUF] Add missing code snippets #11075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1"/></startup></configuration>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -9,6 +9,8 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CS</RootNamespace>
<AssemblyName>CS</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -18,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -26,6 +29,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand All @@ -41,6 +45,9 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
// Snippet for S_UE System.ServiceModel.Dispatcher.ExceptionHandler.HandleException
// 06192006 Created by A.Hu

// <snippet0>
// <Snippet0>
using System;
using System.ServiceModel.Dispatcher;

namespace CS
{
public class MyExceptionHandler: ExceptionHandler
public class MyExceptionHandler : ExceptionHandler
{
// HandleException method override gives control to
// your code.
public override bool HandleException ( Exception ex )
{
// This method contains logic to decide whether
// the exception is serious enough
// to terminate the process.
return ShouldTerminateProcess (ex);
}
// HandleException method override gives control to
// your code.
public override bool HandleException(Exception ex)
{
// This method contains logic to decide whether
// the exception is serious enough
// to terminate the process.
return ShouldTerminateProcess(ex);
}

public bool ShouldTerminateProcess (Exception ex)
{
// Write your logic here.
return true;
}
public bool ShouldTerminateProcess(Exception ex)
{
// Write your logic here.
return true;
}
}
// </Snippet0>

// </snippet0>
class Program
{
// <snippet1>
static void Main(string[] args)
static void Main()
{
// <Snippet1>
// Create an instance of the MyExceptionHandler class.
MyExceptionHandler thisExceptionHandler =
new MyExceptionHandler();
Expand All @@ -43,8 +43,9 @@ static void Main(string[] args)
thisExceptionHandler;

// After the handler is set, write your call to
// System.ServiceModel.ICommunication.Open here
// System.ServiceModel.ICommunication.Open here.

// </Snippet1>
}
}
// </snippet1>
}
96 changes: 49 additions & 47 deletions xml/System.ServiceModel.Dispatcher/ExceptionHandler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@
<Docs>
<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>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
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.
## Examples
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.
<format type="text/markdown"><![CDATA[

## Remarks

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.

## Examples

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.

:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/program.cs" id="Snippet0":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet0":::
The following code example shows how to enable the custom `MyExceptionHandler` for unhandled exceptions that occur within the WCF runtime.
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet0":::

The following code example shows how to enable the custom `MyExceptionHandler` for unhandled exceptions that occur within the WCF runtime.

:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/program.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet1":::

]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -137,13 +137,13 @@
<summary>Gets or sets the current <see cref="T:System.ServiceModel.Dispatcher.ExceptionHandler" /> implementation for the application domain.</summary>
<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>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
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.
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.
<format type="text/markdown"><![CDATA[

## Remarks
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.

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.

]]></format>
</remarks>
</Docs>
Expand All @@ -168,27 +168,28 @@
<Parameter Name="exception" Type="System.Exception" />
</Parameters>
<Docs>
<param name="exception">The exception the occurred within the Windows Communication Foundation (WCF) runtime and which may terminate the application.</param>
<param name="exception">The exception that occurred within the Windows Communication Foundation (WCF) runtime and which might terminate the application.</param>
<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>
<returns>
<see langword="true" /> if the exception has been handled; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
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.



## Examples
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.



The following code example shows how to enable the custom `MyExceptionHandler` for unhandled exceptions that occur within the WCF runtime.



<format type="text/markdown"><![CDATA[

## Remarks
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.

## Examples

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.

:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/program.cs" id="Snippet0":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet0":::

The following code example shows how to enable the custom `MyExceptionHandler` for unhandled exceptions that occur within the WCF runtime.

:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_ueexceptionhandler/cs/program.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_ueexceptionhandler/vb/module1.vb" id="Snippet1":::

]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -223,13 +224,14 @@
<summary>Gets or sets the current transport <see cref="T:System.ServiceModel.Dispatcher.ExceptionHandler" /> implementation for the application domain.</summary>
<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>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
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.

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.

<format type="text/markdown"><![CDATA[

## Remarks

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.

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.

]]></format>
</remarks>
</Docs>
Expand Down