diff --git a/docs/architecture/blazor-for-web-forms-developers/components.md b/docs/architecture/blazor-for-web-forms-developers/components.md
index b286a9ddb7361..03c284e4b77e5 100644
--- a/docs/architecture/blazor-for-web-forms-developers/components.md
+++ b/docs/architecture/blazor-for-web-forms-developers/components.md
@@ -269,7 +269,7 @@ public partial class Counter : System.Web.UI.UserControl
}
```
-In Blazor, you can register handlers for DOM UI events directly using directive attributes of the form `@on{event}`. The `{event}` placeholder represents the name of the event. For example, you can listen for button clicks like this:
+In Blazor, you can register handlers for DOM UI events directly `using` directive attributes of the form `@on{event}`. The `{event}` placeholder represents the name of the event. For example, you can listen for button clicks like this:
```razor
diff --git a/docs/architecture/blazor-for-web-forms-developers/security-authentication-authorization.md b/docs/architecture/blazor-for-web-forms-developers/security-authentication-authorization.md
index 120bf78e48e85..97cf8f1857557 100644
--- a/docs/architecture/blazor-for-web-forms-developers/security-authentication-authorization.md
+++ b/docs/architecture/blazor-for-web-forms-developers/security-authentication-authorization.md
@@ -278,7 +278,7 @@ builder.Services.AddDefaultIdentity(options =>
.AddEntityFrameworkStores();
```
-The `AddDefaultIdentity` extension method is used to configure Identity to use the default `ApplicationDbContext` and the framework's `IdentityUser` type. If you're using a custom `IdentityUser`, be sure to specify its type here. If these extension methods aren't working in your application, check that you have the appropriate using statements and that you have the necessary NuGet package references. For example, your project should have some version of the `Microsoft.AspNetCore.Identity.EntityFrameworkCore` and `Microsoft.AspNetCore.Identity.UI` packages referenced.
+The `AddDefaultIdentity` extension method is used to configure Identity to use the default `ApplicationDbContext` and the framework's `IdentityUser` type. If you're using a custom `IdentityUser`, be sure to specify its type here. If these extension methods aren't working in your application, check that you have the appropriate `using` directives and that you have the necessary NuGet package references. For example, your project should have some version of the `Microsoft.AspNetCore.Identity.EntityFrameworkCore` and `Microsoft.AspNetCore.Identity.UI` packages referenced.
Also in *Program.cs* you should see the necessary middleware configured for the site. Specifically, `UseAuthentication` and `UseAuthorization` should be set up, and in the proper location.
diff --git a/docs/azure/sdk/includes/implement-defaultazurecredential.md b/docs/azure/sdk/includes/implement-defaultazurecredential.md
index 46ff358c05d47..996599b669055 100644
--- a/docs/azure/sdk/includes/implement-defaultazurecredential.md
+++ b/docs/azure/sdk/includes/implement-defaultazurecredential.md
@@ -23,7 +23,7 @@ Right click on your project node in Visual Studio and select **Manage NuGet Pack
Azure services are generally accessed using corresponding client classes from the SDK. These classes and your own custom services should be registered in the `Program.cs` file so they can be accessed via dependency injection throughout your app. Inside of `Program.cs`, follow the steps below to correctly setup your service and `DefaultAzureCredential`.
-1. Include the `Azure.Identity` and `Microsoft.Extensions.Azure` namespaces with a using statement.
+1. Include the `Azure.Identity` and `Microsoft.Extensions.Azure` namespaces with a `using` directive.
1. Register the Azure service using relevant helper methods.
1. Pass an instance of the `DefaultAzureCredential` object to the `UseCredential` method.
@@ -47,12 +47,12 @@ Alternatively, you can also utilize `DefaultAzureCredential` in your services mo
using Azure.Identity;
// Inside of Program.cs
-builder.Services.AddSingleton(x =>
+builder.Services.AddSingleton(x =>
new BlobServiceClient(
new Uri("https://.blob.core.windows.net"),
new DefaultAzureCredential()));
```
-When the above code is run on your local workstation during local development, it will look in the environment variables for an application service principal or at Visual Studio, VS Code, the Azure CLI, or Azure PowerShell for a set of developer credentials, either of which can be used to authenticate the app to Azure resources during local development.
+When the above code is run on your local workstation during local development, it will look in the environment variables for an application service principal or at Visual Studio, VS Code, the Azure CLI, or Azure PowerShell for a set of developer credentials, either of which can be used to authenticate the app to Azure resources during local development.
When deployed to Azure this same code can also authenticate your app to other Azure resources. `DefaultAzureCredential` can retrieve environment settings and managed identity configurations to authenticate to other services automatically.
diff --git a/docs/core/compatibility/sdk/8.0/implicit-global-using-netfx.md b/docs/core/compatibility/sdk/8.0/implicit-global-using-netfx.md
index 99e5af5059471..a3caa8d2c18a6 100644
--- a/docs/core/compatibility/sdk/8.0/implicit-global-using-netfx.md
+++ b/docs/core/compatibility/sdk/8.0/implicit-global-using-netfx.md
@@ -29,10 +29,10 @@ Default projects should compile.
## Recommended action
-If you relied on the implicit global using directive, you can:
+If you relied on the implicit global `using` directive, you can:
-- Add a [global using directive](../../../../csharp/language-reference/keywords/using-directive.md#global-modifier) to one of your source files.
-- Add a using directive to each source code file that uses APIs from System.Net.Http.
+- Add a [global `using` directive](../../../../csharp/language-reference/keywords/using-directive.md#global-modifier) to one of your source files.
+- Add a `using` directive to each source code file that uses APIs from System.Net.Http.
## Affected APIs
diff --git a/docs/core/diagnostics/distributed-tracing-instrumentation-walkthroughs.md b/docs/core/diagnostics/distributed-tracing-instrumentation-walkthroughs.md
index 5365970e922c3..6351d5e1b3f3d 100644
--- a/docs/core/diagnostics/distributed-tracing-instrumentation-walkthroughs.md
+++ b/docs/core/diagnostics/distributed-tracing-instrumentation-walkthroughs.md
@@ -113,8 +113,8 @@ Applications and libraries add distributed tracing instrumentation using the
### ActivitySource
First create an instance of ActivitySource. ActivitySource provides APIs to create and
-start Activity objects. Add the static ActivitySource variable above Main() and
-`using System.Diagnostics;` to the using statements.
+start Activity objects. Add the static ActivitySource variable above `Main()` and
+`using System.Diagnostics;` to the `using` directives.
```csharp
using OpenTelemetry;
diff --git a/docs/core/extensions/dependency-injection-usage.md b/docs/core/extensions/dependency-injection-usage.md
index ee44433c72d4a..05f6b9c0726a0 100644
--- a/docs/core/extensions/dependency-injection-usage.md
+++ b/docs/core/extensions/dependency-injection-usage.md
@@ -100,8 +100,8 @@ Update *Program.cs* with the following code:
Each `services.Add{LIFETIME}<{SERVICE}>` extension method adds (and potentially configures) services. We recommend that apps follow this convention. Don't place extension methods in the namespace unless you're authoring an official Microsoft package. Extension methods that are defined within the `Microsoft.Extensions.DependencyInjection` namespace:
-- Are displayed in [IntelliSense](/visualstudio/ide/using-intellisense) without requiring additional `using` blocks.
-- Reduce the number of required `using` statements in the `Program` or `Startup` classes where these extension methods are typically called.
+- Are displayed in [IntelliSense](/visualstudio/ide/using-intellisense) without requiring additional `using` directives.
+- Reduce the number of required `using` directives in the `Program` or `Startup` classes where these extension methods are typically called.
The app:
diff --git a/docs/core/extensions/file-globbing.md b/docs/core/extensions/file-globbing.md
index 577fe102fa073..44c19e4b6154b 100644
--- a/docs/core/extensions/file-globbing.md
+++ b/docs/core/extensions/file-globbing.md
@@ -91,7 +91,7 @@ The preceding C# code:
- Calls `Execute` given the `DirectoryInfoWrapper` instance to yield a object.
> [!NOTE]
-> The `DirectoryInfoWrapper` type is defined in the `Microsoft.Extensions.FileSystemGlobbing.Abstractions` namespace, and the `DirectoryInfo` type is defined in the `System.IO` namespace. To avoid unnecessary `using` statements, you can use the provided extension methods.
+> The `DirectoryInfoWrapper` type is defined in the `Microsoft.Extensions.FileSystemGlobbing.Abstractions` namespace, and the `DirectoryInfo` type is defined in the `System.IO` namespace. To avoid unnecessary `using` directives, you can use the provided extension methods.
There is another extension method that yields an `IEnumerable` representing the matching files:
@@ -146,7 +146,7 @@ The additional `Match` overloads work in similar ways.
The patterns that are specified in the `AddExclude` and `AddInclude` methods can use the following formats to match multiple files or directories.
- Exact directory or file name
-
+
- `some-file.txt`
- `path/to/file.txt`
diff --git a/docs/core/extensions/windows-service-with-installer.md b/docs/core/extensions/windows-service-with-installer.md
index 76ec682b62e6a..9f7e5d3a1863a 100644
--- a/docs/core/extensions/windows-service-with-installer.md
+++ b/docs/core/extensions/windows-service-with-installer.md
@@ -73,7 +73,7 @@ dotnet add App.WindowsService.csproj package CliWrap
For more information, see [dotnet add package](../tools/dotnet-add-package.md).
-With `CliWrap` installed, open the _Program.cs_ file of the `App.WindowsService` project. After the `using` statements, but before the `IHost` is created, add the following code:
+With `CliWrap` installed, open the _Program.cs_ file of the `App.WindowsService` project. After the `using` directives, but before the `IHost` is created, add the following code:
```csharp
using CliWrap;
@@ -86,7 +86,7 @@ if (args is { Length: 1 })
{
string executablePath =
Path.Combine(AppContext.BaseDirectory, "App.WindowsService.exe");
-
+
if (args[0] is "/Install")
{
await Cli.Wrap("sc")
@@ -98,7 +98,7 @@ if (args is { Length: 1 })
await Cli.Wrap("sc")
.WithArguments(new[] { "stop", ServiceName })
.ExecuteAsync();
-
+
await Cli.Wrap("sc")
.WithArguments(new[] { "delete", ServiceName })
.ExecuteAsync();
@@ -181,7 +181,7 @@ After the project reference has been added, configure the _Package.wxs_ file. Op
Version="$(Version)"
UpgradeCode="$(var.UpgradeCode)"
Compressed="true">
-
+
@@ -204,7 +204,7 @@ After the project reference has been added, configure the _Package.wxs_ file. Op
-
+
[!NOTE]
-> The `using` keyword is also used to create *using statements*, which help ensure that objects such as files and fonts are handled correctly. For more information about the *using statement*, see [using statement](../statements/using.md).
+> The `using` keyword is also used to create *`using` statements*, which help ensure that objects such as files and fonts are handled correctly. For more information about the *`using` statement*, see [`using` statement](../statements/using.md).
The scope of a `using` directive without the `global` modifier is the file in which it appears.
diff --git a/docs/csharp/language-reference/keywords/using.md b/docs/csharp/language-reference/keywords/using.md
index d20b4731da82c..7a5cb2e742279 100644
--- a/docs/csharp/language-reference/keywords/using.md
+++ b/docs/csharp/language-reference/keywords/using.md
@@ -2,9 +2,9 @@
title: "using keyword"
description: "using keyword - C# reference"
ms.date: 04/05/2019
-f1_keywords:
+f1_keywords:
- "using"
-helpviewer_keywords:
+helpviewer_keywords:
- "using keyword [C#]"
ms.assetid: 124e1a63-2a4b-4132-b269-3b6d8d3ef72d
---
@@ -12,11 +12,11 @@ ms.assetid: 124e1a63-2a4b-4132-b269-3b6d8d3ef72d
The `using` keyword has two major uses:
-- The [using statement](../statements/using.md) defines a scope at the end of which an object is disposed:
+- The [`using` statement](../statements/using.md) defines a scope at the end of which an object is disposed:
:::code language="csharp" source="./snippets/UsingKeywordExample.cs" id="UsingStatement":::
-- The [using directive](using-directive.md) creates an alias for a namespace or imports types defined in other namespaces:
+- The [`using` directive](using-directive.md) creates an alias for a namespace or imports types defined in other namespaces:
:::code language="csharp" source="./snippets/UsingKeywordExample.cs" id="UsingDirective":::
diff --git a/docs/csharp/language-reference/operators/new-operator.md b/docs/csharp/language-reference/operators/new-operator.md
index 39e57bbc209b8..a3c575b51fd78 100644
--- a/docs/csharp/language-reference/operators/new-operator.md
+++ b/docs/csharp/language-reference/operators/new-operator.md
@@ -4,7 +4,7 @@ description: "The C# new operator is used to create a optionally initialize a ne
ms.date: 11/28/2022
f1_keywords:
- new_CSharpKeyword
-helpviewer_keywords:
+helpviewer_keywords:
- "new operator keyword [C#]"
ms.assetid: a212b697-a79b-4105-9923-1f7b108036e8
---
@@ -54,7 +54,7 @@ To create an instance of an [anonymous type](../../fundamentals/types/anonymous-
You don't have to destroy earlier created type instances. Instances of both reference and value types are destroyed automatically. Instances of value types are destroyed as soon as the context that contains them is destroyed. Instances of reference types are destroyed by the [garbage collector](../../../standard/garbage-collection/index.md) at some unspecified time after the last reference to them is removed.
-For type instances that contain unmanaged resources, for example, a file handle, it's recommended to employ deterministic clean-up to ensure that the resources they contain are released as soon as possible. For more information, see the API reference and the [using statement](../statements/using.md) article.
+For type instances that contain unmanaged resources, for example, a file handle, it's recommended to employ deterministic clean-up to ensure that the resources they contain are released as soon as possible. For more information, see the API reference and the [`using` statement](../statements/using.md) article.
## Operator overloadability
diff --git a/docs/csharp/language-reference/xmldoc/recommended-tags.md b/docs/csharp/language-reference/xmldoc/recommended-tags.md
index df36f06bcf990..52c5d9f7c20ed 100644
--- a/docs/csharp/language-reference/xmldoc/recommended-tags.md
+++ b/docs/csharp/language-reference/xmldoc/recommended-tags.md
@@ -108,7 +108,7 @@ XML documentation starts with `///`. When you create a new project, the template
- The documentation must be well-formed XML. If the XML isn't well formed, the compiler generates a warning. The documentation file will contain a comment that says that an error was encountered.
- Some of the recommended tags have special meanings:
- The `` tag is used to describe parameters. If used, the compiler verifies that the parameter exists and that all parameters are described in the documentation. If the verification fails, the compiler issues a warning.
- - The `cref` attribute can be attached to any tag to reference a code element. The compiler verifies that this code element exists. If the verification fails, the compiler issues a warning. The compiler respects any `using` statements when it looks for a type described in the `cref` attribute.
+ - The `cref` attribute can be attached to any tag to reference a code element. The compiler verifies that this code element exists. If the verification fails, the compiler issues a warning. The compiler respects any `using` directives when it looks for a type described in the `cref` attribute.
- The `` tag is used by IntelliSense inside Visual Studio to display additional information about a type or member.
> [!NOTE]
> The XML file does not provide full information about the type and members (for example, it does not contain any type information). To get full information about a type or member, use the documentation file together with reflection on the actual type or member.
@@ -295,15 +295,15 @@ The `` tag lets you specify an example of how to use a method or other
### \
-```xml
+```xml
-```
+```
Inherit XML comments from base classes, interfaces, and similar methods. Using `inheritdoc` eliminates unwanted copying and pasting of duplicate XML comments and automatically keeps XML comments synchronized. Note that when you add the `` tag to a type, all members will inherit the comments as well.
- `cref`: Specify the member to inherit documentation from. Already defined tags on the current member are not overridden by the inherited ones.
- `path`: The XPath expression query that will result in a node set to show. You can use this attribute to filter the tags to include or exclude from the inherited documentation.
-
+
Add your XML comments in base classes or interfaces and let inheritdoc copy the comments to implementing classes. Add your XML comments to your synchronous methods and let inheritdoc copy the comments to your asynchronous versions of the same methods. If you want to copy the comments from a specific member, you use the `cref` attribute to specify the member.
### \
diff --git a/docs/csharp/misc/cs0210.md b/docs/csharp/misc/cs0210.md
index a4de6bd30ce5a..93cd1b9e11642 100644
--- a/docs/csharp/misc/cs0210.md
+++ b/docs/csharp/misc/cs0210.md
@@ -2,67 +2,67 @@
description: "Compiler Error CS0210"
title: "Compiler Error CS0210"
ms.date: 07/20/2015
-f1_keywords:
+f1_keywords:
- "CS0210"
-helpviewer_keywords:
+helpviewer_keywords:
- "CS0210"
ms.assetid: 9f2ec1b8-6ca4-4147-b004-e3b43e7e8754
---
# Compiler Error CS0210
-You must provide an initializer in a fixed or using statement declaration
-
- You must declare and initialize the variable in a [fixed statement](../language-reference/statements/fixed.md). For more information, see [Unsafe Code and Pointers](../language-reference/unsafe-code.md).
-
- The following sample generates CS0210:
-
-```csharp
-// CS0210a.cs
-// compile with: /unsafe
-
-class Point
-{
- public int x, y;
-}
-
-public class MyClass
-{
- unsafe public static void Main()
- {
- Point pt = new Point();
-
- fixed (int i) // CS0210
- {
- }
- // try the following lines instead
- /*
- fixed (int* p = &pt.x)
- {
- }
- fixed (int* q = &pt.y)
- {
- }
- */
- }
-}
-```
-
- The following sample also generates CS0210 because the [using statement](../language-reference/statements/using.md) has no initializer.
-
-```csharp
-// CS0210b.cs
-
-using System.IO;
+You must provide an initializer in a fixed or `using` statement declaration
+
+ You must declare and initialize the variable in a [fixed statement](../language-reference/statements/fixed.md). For more information, see [Unsafe Code and Pointers](../language-reference/unsafe-code.md).
+
+ The following sample generates CS0210:
+
+```csharp
+// CS0210a.cs
+// compile with: /unsafe
+
+class Point
+{
+ public int x, y;
+}
+
+public class MyClass
+{
+ unsafe public static void Main()
+ {
+ Point pt = new Point();
+
+ fixed (int i) // CS0210
+ {
+ }
+ // try the following lines instead
+ /*
+ fixed (int* p = &pt.x)
+ {
+ }
+ fixed (int* q = &pt.y)
+ {
+ }
+ */
+ }
+}
+```
+
+ The following sample also generates CS0210 because the [`using` statement](../language-reference/statements/using.md) has no initializer.
+
+```csharp
+// CS0210b.cs
+
+using System.IO;
class Test
-{
+{
static void Main()
- {
- using (StreamWriter w) // CS0210
- // Try this line instead:
+ {
+ using (StreamWriter w) // CS0210
+ // Try this line instead:
// using (StreamWriter w = new StreamWriter("TestFile.txt"))
- {
- w.WriteLine("Hello there");
- }
- }
-}
+ {
+ w.WriteLine("Hello there");
+ }
+ }
+}
```
diff --git a/docs/csharp/misc/cs1702.md b/docs/csharp/misc/cs1702.md
index c7a3c95568468..7d40cfda76806 100644
--- a/docs/csharp/misc/cs1702.md
+++ b/docs/csharp/misc/cs1702.md
@@ -2,14 +2,14 @@
description: "Learn more about: Compiler Warning (level 3) CS1702"
title: "Compiler Warning (level 3) CS1702"
ms.date: 07/20/2015
-f1_keywords:
+f1_keywords:
- "CS1702"
-helpviewer_keywords:
+helpviewer_keywords:
- "CS1702"
ms.assetid: 106b9994-c762-44b9-942e-5417cf3dbbab
---
# Compiler Warning (level 3) CS1702
-Assuming assembly reference "Assembly Name #1" matches "Assembly Name #2", you may need to supply runtime policy
-
- The two assembly references have differing build and/or revision numbers, so will not automatically unify. You may need to supply run-time policy to force unification by using directives in the application .config file.
+Assuming assembly reference "Assembly Name #1" matches "Assembly Name #2", you may need to supply runtime policy
+
+ The two assembly references have differing build and/or revision numbers, so will not automatically unify. You may need to supply run-time policy to force unification by `using` directives in the application .config file.
diff --git a/docs/csharp/misc/cs1935.md b/docs/csharp/misc/cs1935.md
index 475846950a1e2..0ac682248bc4d 100644
--- a/docs/csharp/misc/cs1935.md
+++ b/docs/csharp/misc/cs1935.md
@@ -2,9 +2,9 @@
description: "Learn more about: Compiler Error CS1935"
title: "Compiler Error CS1935"
ms.date: 07/20/2015
-f1_keywords:
+f1_keywords:
- "CS1935"
-helpviewer_keywords:
+helpviewer_keywords:
- "CS1935"
ms.assetid: d5dda801-fbf3-4340-bfe1-f9409f2d344d
---
@@ -16,7 +16,7 @@ The source type in a query must be `IEnumerable`, `IEnumerable`, or a derived
## To correct this error
-Add the required using directives and references to the project.
+Add the required `using` directives and references to the project.
## Example
diff --git a/docs/csharp/programming-guide/classes-and-structs/finalizers.md b/docs/csharp/programming-guide/classes-and-structs/finalizers.md
index e1bfb205f8262..8c6e4ceefa6c7 100644
--- a/docs/csharp/programming-guide/classes-and-structs/finalizers.md
+++ b/docs/csharp/programming-guide/classes-and-structs/finalizers.md
@@ -2,7 +2,7 @@
title: "Finalizers"
description: Finalizers in C# perform any necessary final clean-up when a class instance is being collected by the garbage collector.
ms.date: 08/20/2021
-helpviewer_keywords:
+helpviewer_keywords:
- "~ [C#], in finalizers"
- "C# language, finalizers"
- "finalizers [C#]"
@@ -11,7 +11,7 @@ helpviewer_keywords:
Finalizers (historically referred to as **destructors**) are used to perform any necessary final clean-up when a class instance is being collected by the garbage collector. In most cases, you can avoid writing a finalizer by using the or derived classes to wrap any unmanaged handle.
-## Remarks
+## Remarks
- Finalizers cannot be defined in structs. They are only used with classes.
- A class can only have one finalizer.
@@ -52,7 +52,7 @@ The programmer has no control over when the finalizer is called; the garbage col
> [!NOTE]
> Whether or not finalizers are run as part of application termination is specific to each [implementation of .NET](../../../standard/glossary.md#implementation-of-net). When an application terminates, .NET Framework makes every reasonable effort to call finalizers for objects that haven't yet been garbage collected, unless such cleanup has been suppressed (by a call to the library method `GC.SuppressFinalize`, for example). .NET 5 (including .NET Core) and later versions don't call finalizers as part of application termination. For more information, see GitHub issue [dotnet/csharpstandard #291](https://github.com/dotnet/csharpstandard/issues/291).
-
+
If you need to perform cleanup reliably when an application exits, register a handler for the event. That handler would ensure (or, ) has been called for all objects that require cleanup before application exit. Because you can't call *Finalize* directly, and you can't guarantee the garbage collector calls all finalizers before exit, you must use `Dispose` or `DisposeAsync` to ensure resources are freed.
## Using finalizers to release resources
@@ -63,12 +63,12 @@ In general, C# does not require as much memory management on the part of the dev
If your application is using an expensive external resource, we also recommend that you provide a way to explicitly release the resource before the garbage collector frees the object. To release the resource, implement a `Dispose` method from the interface that performs the necessary cleanup for the object. This can considerably improve the performance of the application. Even with this explicit control over resources, the finalizer becomes a safeguard to clean up resources if the call to the `Dispose` method fails.
-For more information about cleaning up resources, see the following articles:
+For more information about cleaning up resources, see the following articles:
- [Cleaning Up Unmanaged Resources](../../../standard/garbage-collection/unmanaged.md)
- [Implementing a Dispose Method](../../../standard/garbage-collection/implementing-dispose.md)
- [Implementing a DisposeAsync Method](../../../standard/garbage-collection/implementing-disposeasync.md)
-- [using statement](../../language-reference/statements/using.md)
+- [`using` statement](../../language-reference/statements/using.md)
## Example
@@ -78,11 +78,11 @@ The following example creates three classes that make a chain of inheritance. Th
* .NET 5 (including .NET Core) or a later version: There's no output, because this implementation of .NET doesn't call finalizers when the application terminates.
:::code language="csharp" source="snippets/finalizers/Program.cs" ID="Snippet1":::
-
-## C# language specification
+
+## C# language specification
For more information, see the [Finalizers](~/_csharpstandard/standard/classes.md#1513-finalizers) section of the [C# Language Specification](~/_csharpstandard/standard/README.md).
-
+
## See also
-
diff --git a/docs/csharp/programming-guide/classes-and-structs/implicitly-typed-local-variables.md b/docs/csharp/programming-guide/classes-and-structs/implicitly-typed-local-variables.md
index ddce26f1c4b45..0e011e909526b 100644
--- a/docs/csharp/programming-guide/classes-and-structs/implicitly-typed-local-variables.md
+++ b/docs/csharp/programming-guide/classes-and-structs/implicitly-typed-local-variables.md
@@ -2,7 +2,7 @@
title: "Implicitly typed local variables"
description: The var keyword in C# instructs the compiler to infer the type of the variable from the expression on the right side of the initialization statement.
ms.date: 07/20/2015
-helpviewer_keywords:
+helpviewer_keywords:
- "implicitly-typed local variables [C#]"
- "var [C#]"
ms.assetid: b9218fb2-ef5d-4814-8a8e-2bc29b0bbc9b
@@ -96,4 +96,4 @@ The use of `var` helps simplify your code, but its use should be restricted to c
- [LINQ in C#](../../linq/index.md)
- [LINQ (Language-Integrated Query)](../../linq/index.md)
- [Iteration statements](../../language-reference/statements/iteration-statements.md)
-- [using statement](../../language-reference/statements/using.md)
+- [`using` statement](../../language-reference/statements/using.md)
diff --git a/docs/csharp/roslyn-sdk/get-started/semantic-analysis.md b/docs/csharp/roslyn-sdk/get-started/semantic-analysis.md
index 95219d26b316a..16fadf95e6d6f 100644
--- a/docs/csharp/roslyn-sdk/get-started/semantic-analysis.md
+++ b/docs/csharp/roslyn-sdk/get-started/semantic-analysis.md
@@ -61,11 +61,11 @@ Once you have a you can ask it for a <
## Binding a name
-The creates the from the . After creating the model, you can query it to find the first `using` directive, and retrieve the symbol information for the `System` namespace. Add these two lines to your `Main` method to create the semantic model and retrieve the symbol for the first using statement:
+The creates the from the . After creating the model, you can query it to find the first `using` directive, and retrieve the symbol information for the `System` namespace. Add these two lines to your `Main` method to create the semantic model and retrieve the symbol for the first `using` directive:
-[!code-csharp[Find the namespace symbol for the first using](../../../../samples/snippets/csharp/roslyn-sdk/SemanticQuickStart/Program.cs#5 "Find the namespace symbol for the first using")]
+[!code-csharp[Find the namespace symbol for the first using](../../../../samples/snippets/csharp/roslyn-sdk/SemanticQuickStart/Program.cs#5)]
-The preceding code shows how to bind the name in the first `using` directive to retrieve a for the `System` namespace. The preceding code also illustrates that you use the **syntax model** to find the structure of the code; you use the **semantic model** to understand its meaning. The **syntax model** finds the string `System` in the using statement. The **semantic model** has all the information about the types defined in the `System` namespace.
+The preceding code shows how to bind the name in the first `using` directive to retrieve a for the `System` namespace. The preceding code also illustrates that you use the **syntax model** to find the structure of the code; you use the **semantic model** to understand its meaning. The **syntax model** finds the string `System` in the `using` directive. The **semantic model** has all the information about the types defined in the `System` namespace.
From the object you can obtain the using the property. This property returns the symbol this expression refers to. For expressions that don't refer to anything (such as numeric literals) this property is `null`. When the is not null, the denotes the type of the symbol. In this example, the property is a . Add the following code to your `Main` method. It retrieves the symbol for the `System` namespace and then displays all the child namespaces declared in the `System` namespace:
diff --git a/docs/csharp/roslyn-sdk/get-started/syntax-analysis.md b/docs/csharp/roslyn-sdk/get-started/syntax-analysis.md
index 1b787d4b4fea5..d4f83a43e4ffd 100644
--- a/docs/csharp/roslyn-sdk/get-started/syntax-analysis.md
+++ b/docs/csharp/roslyn-sdk/get-started/syntax-analysis.md
@@ -29,7 +29,7 @@ namespace HelloWorld
Look at the text of the previous program. You recognize familiar elements. The entire text represents a single source file, or a **compilation unit**. The first three lines of that source file are **using directives**. The remaining source is contained in a **namespace declaration**. The namespace declaration contains a child **class declaration**. The class declaration contains one **method declaration**.
-The Syntax API creates a tree structure with the root representing the compilation unit. Nodes in the tree represent the using directives, namespace declaration and all the other elements of the program. The tree structure continues down to the lowest levels: the string "Hello World!" is a **string literal token** that is a descendent of an **argument**. The Syntax API provides access to the structure of the program. You can query for specific code practices, walk the entire tree to understand the code, and create new trees by modifying the existing tree.
+The Syntax API creates a tree structure with the root representing the compilation unit. Nodes in the tree represent the `using` directives, namespace declaration and all the other elements of the program. The tree structure continues down to the lowest levels: the string "Hello World!" is a **string literal token** that is a descendent of an **argument**. The Syntax API provides access to the structure of the program. You can query for specific code practices, walk the entire tree to understand the code, and create new trees by modifying the existing tree.
That brief description provides an overview of the kind of information accessible using the Syntax API. The Syntax API is nothing more than a formal API that describes the familiar code constructs you know from C#. The full capabilities include information about how the code is formatted including line breaks, white space, and indenting. Using this information, you can fully represent the code as written and read by human programmers or the compiler. Using this structure enables you to interact with the source code on a deeply meaningful level. It's no longer text strings, but data that represents the structure of a C# program.
@@ -107,14 +107,14 @@ Now that you know the declaration is a class to query code. It would be cumbersome to visit every node in the root syntax tree to find using declarations. Instead, you create a derived class and override the method that gets called only when the current node in the tree is a using directive. Your visitor does not do any work on any other node types. This single method examines each of the `using` statements and builds a collection of the namespaces that aren't in the `System` namespace. You build a that examines all the `using` statements, but only the `using` statements.
+This source text contains `using` directives scattered across four different locations: the file-level, in the top-level namespace, and in the two nested namespaces. This example highlights a core scenario for using the class to query code. It would be cumbersome to visit every node in the root syntax tree to find using declarations. Instead, you create a derived class and override the method that gets called only when the current node in the tree is a `using` directive. Your visitor does not do any work on any other node types. This single method examines each of the `using` directives and builds a collection of the namespaces that aren't in the `System` namespace. You build a that examines all the `using` directives, but only the `using` directives.
Now that you've defined the program text, you need to create a `SyntaxTree` and get the root of that tree:
@@ -183,9 +183,9 @@ The base class, implemen
As with the earlier example, you've added a variety of `WriteLine` statements to aid in understanding of this method. You can see when it's called, and what arguments are passed to it each time.
-Finally, you need to add two lines of code to create the `UsingCollector` and have it visit the root node, collecting all the `using` statements. Then, add a `foreach` loop to display all the `using` statements your collector found:
+Finally, you need to add two lines of code to create the `UsingCollector` and have it visit the root node, collecting all the `using` directives. Then, add a `foreach` loop to display all the `using` directives your collector found:
-[!code-csharp[Create the UsingCollector and visit the root node.](../../../../samples/snippets/csharp/roslyn-sdk/SyntaxQuickStart/SyntaxWalker/Program.cs#6 "Create the UsingCollector and visit the root node.")]
+[!code-csharp[Create the UsingCollector and visit the root node.](../../../../samples/snippets/csharp/roslyn-sdk/SyntaxQuickStart/SyntaxWalker/Program.cs#6)]
Compile and run the program. You should see the following output:
@@ -215,4 +215,4 @@ Microsoft.CSharp
Press any key to continue . . .
```
-Congratulations! You've used the **Syntax API** to locate specific kinds of C# statements and declarations in C# source code.
+Congratulations! You've used the **Syntax API** to locate specific kinds of directives and declarations in C# source code.
diff --git a/docs/csharp/roslyn-sdk/get-started/syntax-transformation.md b/docs/csharp/roslyn-sdk/get-started/syntax-transformation.md
index 25873a61c2b8a..5eca2838d8f9f 100644
--- a/docs/csharp/roslyn-sdk/get-started/syntax-transformation.md
+++ b/docs/csharp/roslyn-sdk/get-started/syntax-transformation.md
@@ -28,7 +28,7 @@ Start Visual Studio, and create a new C# **Stand-Alone Code Analysis Tool** proj
This project uses the class methods to construct a representing the `System.Collections.Generic` namespace.
-Add the following using directive to the top of the `Program.cs`.
+Add the following `using` directive to the top of the `Program.cs`.
[!code-csharp[import the SyntaxFactory class](../../../../samples/snippets/csharp/roslyn-sdk/SyntaxTransformationQuickStart/ConstructionCS/Program.cs#StaticUsings "import the Syntax Factory class and the System.Console class")]
@@ -92,7 +92,7 @@ Create a new C# **Stand-Alone Code Analysis Tool** project. In Visual Studio, ri
The first step is to create a class that derives from to perform your transformations. Add a new class file to the project. In Visual Studio, choose **Project** > **Add Class...**. In the **Add New Item** dialog type `TypeInferenceRewriter.cs` as the filename.
-Add the following using directives to the `TypeInferenceRewriter.cs` file:
+Add the following `using` directives to the `TypeInferenceRewriter.cs` file:
[!code-csharp[add necessary usings](../../../../samples/snippets/csharp/roslyn-sdk/SyntaxTransformationQuickStart/TransformationCS/TypeInferenceRewriter.cs#AddUsings "Add required usings")]
diff --git a/docs/csharp/tutorials/top-level-statements.md b/docs/csharp/tutorials/top-level-statements.md
index 140f481b92afa..36c84740e68c3 100644
--- a/docs/csharp/tutorials/top-level-statements.md
+++ b/docs/csharp/tutorials/top-level-statements.md
@@ -104,13 +104,13 @@ This code answers the questions, but let's add one more feature. You'd like your
:::code language="csharp" source="snippets/top-level-statements/UtilitiesPassOne.cs" ID="AnimationFirstPass":::
-You'll also need to add a `using` statement to the top of the source file:
+You'll also need to add a `using` directive to the top of the source file:
```csharp
using System.Threading.Tasks;
```
-The `using` statements must be before any other statements in the file. Otherwise, it's a compiler error. You can run the program again and see the animation. That makes a better experience. Experiment with the length of the delay to match your taste.
+The `using` directives must be before any other statements in the file. Otherwise, it's a compiler error. You can run the program again and see the animation. That makes a better experience. Experiment with the length of the delay to match your taste.
The preceding code creates a set of spinning lines separated by a space. Adding the `await` keyword instructs the compiler to generate the program entry point as a method that has the `async` modifier, and returns a . This program doesn't return a value, so the program entry point returns a `Task`. If your program returns an integer value, you would add a return statement to the end of your top-level statements. That return statement would specify the integer value to return. If your top-level statements include an `await` expression, the return type becomes .
@@ -206,7 +206,7 @@ Now you have a complete application, and you've refactored the reusable parts fo
:::code language="csharp" source="snippets/top-level-statements/Program.cs":::
-The preceding example adds the call to `Utilities.ShowConsoleAnimation`, and adds an additional `using` statement.
+The preceding example adds the call to `Utilities.ShowConsoleAnimation`, and adds an additional `using` directive.
## Summary
diff --git a/docs/csharp/tutorials/working-with-linq.md b/docs/csharp/tutorials/working-with-linq.md
index 2e45256015957..e5c1fac8d9ca2 100644
--- a/docs/csharp/tutorials/working-with-linq.md
+++ b/docs/csharp/tutorials/working-with-linq.md
@@ -45,7 +45,7 @@ using System.Collections.Generic;
using System.Linq;
```
-If these three lines (`using` statements) aren't at the top of the file, our program will not compile.
+If these three lines (`using` directives) aren't at the top of the file, your program might not compile.
Now that you have all of the references that you'll need, consider what constitutes a deck of cards. Commonly, a deck of playing cards has four suits, and each suit has thirteen values. Normally, you might consider creating a `Card` class right off the bat and populating a collection of `Card` objects by hand. With LINQ, you can be more concise than the usual way of dealing with creating a deck of cards. Instead of creating a `Card` class, you can create two sequences to represent suits and ranks, respectively. You'll create a really simple pair of [*iterator methods*](../iterators.md#enumeration-sources-with-iterator-methods) that will generate the ranks and suits as s of strings:
diff --git a/docs/framework/data/adonet/ef/how-to-build-an-entityconnection-connection-string.md b/docs/framework/data/adonet/ef/how-to-build-an-entityconnection-connection-string.md
index afd999514523d..dafd3828deca3 100644
--- a/docs/framework/data/adonet/ef/how-to-build-an-entityconnection-connection-string.md
+++ b/docs/framework/data/adonet/ef/how-to-build-an-entityconnection-connection-string.md
@@ -2,31 +2,31 @@
description: "Learn more about: How to: Build an EntityConnection Connection String"
title: "How to: Build an EntityConnection Connection String"
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
ms.assetid: 5bd1a748-3df7-4d0a-a607-14f25e3175e9
---
# How to: Build an EntityConnection Connection String
-This topic provides an example of how to build an .
-
-### To run the code in this example
-
-1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
-
+This article provides an example of how to build an .
+
+## To run the code in this example
+
+1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
+
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
+
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
- [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
-
-## Example
+ [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
+
+## Example
+
+ The following example initializes the for the underlying provider, then initializes the object and passes this object to the constructor of the .
- The following example initializes the for the underlying provider, then initializes the object and passes this object to the constructor of the .
-
[!code-csharp[DP EntityServices Concepts#BuildingConnectionStringWithEntityCommand](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#buildingconnectionstringwithentitycommand)]
- [!code-vb[DP EntityServices Concepts#BuildingConnectionStringWithEntityCommand](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#buildingconnectionstringwithentitycommand)]
-
+ [!code-vb[DP EntityServices Concepts#BuildingConnectionStringWithEntityCommand](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#buildingconnectionstringwithentitycommand)]
+
## See also
- [How to: Use EntityConnection with an Object Context](/previous-versions/dotnet/netframework-4.0/bb738461(v=vs.100))
diff --git a/docs/framework/data/adonet/ef/how-to-execute-a-parameterized-entity-sql-query-using-entitycommand.md b/docs/framework/data/adonet/ef/how-to-execute-a-parameterized-entity-sql-query-using-entitycommand.md
index 815b558306b84..d608a5978725a 100644
--- a/docs/framework/data/adonet/ef/how-to-execute-a-parameterized-entity-sql-query-using-entitycommand.md
+++ b/docs/framework/data/adonet/ef/how-to-execute-a-parameterized-entity-sql-query-using-entitycommand.md
@@ -15,7 +15,7 @@ This topic shows how to execute an Entity SQL query that has parameters by using
1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
[!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
diff --git a/docs/framework/data/adonet/ef/how-to-execute-a-parameterized-stored-procedure-using-entitycommand.md b/docs/framework/data/adonet/ef/how-to-execute-a-parameterized-stored-procedure-using-entitycommand.md
index a8c47e3360ff7..8f853aa547363 100644
--- a/docs/framework/data/adonet/ef/how-to-execute-a-parameterized-stored-procedure-using-entitycommand.md
+++ b/docs/framework/data/adonet/ef/how-to-execute-a-parameterized-stored-procedure-using-entitycommand.md
@@ -2,33 +2,33 @@
description: "Learn more about: How to: Execute a Parameterized Stored Procedure Using EntityCommand"
title: "How to: Execute a Parameterized Stored Procedure Using EntityCommand"
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
ms.assetid: 4f5639bf-bb7f-4982-bb1d-c7caa4348888
---
# How to: Execute a Parameterized Stored Procedure Using EntityCommand
-This topic shows how to execute a parameterized stored procedure by using the class.
-
-### To run the code in this example
-
-1. Add the [School Model](/previous-versions/dotnet/netframework-4.0/bb896300(v=vs.100)) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
-
+This topic shows how to execute a parameterized stored procedure by using the class.
+
+### To run the code in this example
+
+1. Add the [School Model](/previous-versions/dotnet/netframework-4.0/bb896300(v=vs.100)) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
+
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
+
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
- [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
-
-3. Import the `GetStudentGrades` stored procedure and specify `CourseGrade` entities as a return type. For information on how to import a stored procedure, see [How to: Import a Stored Procedure](/previous-versions/dotnet/netframework-4.0/bb896231(v=vs.100)).
-
-## Example
-
- The following code executes the `GetStudentGrades` stored procedure where `StudentId` is a required parameter. The results are then read by an .
-
+ [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
+
+3. Import the `GetStudentGrades` stored procedure and specify `CourseGrade` entities as a return type. For information on how to import a stored procedure, see [How to: Import a Stored Procedure](/previous-versions/dotnet/netframework-4.0/bb896231(v=vs.100)).
+
+## Example
+
+ The following code executes the `GetStudentGrades` stored procedure where `StudentId` is a required parameter. The results are then read by an .
+
[!code-csharp[DP EntityServices Concepts#StoredProcWithEntityCommand](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#storedprocwithentitycommand)]
- [!code-vb[DP EntityServices Concepts#StoredProcWithEntityCommand](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#storedprocwithentitycommand)]
-
+ [!code-vb[DP EntityServices Concepts#StoredProcWithEntityCommand](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#storedprocwithentitycommand)]
+
## See also
- [EntityClient Provider for the Entity Framework](entityclient-provider-for-the-entity-framework.md)
diff --git a/docs/framework/data/adonet/ef/how-to-execute-a-polymorphic-query.md b/docs/framework/data/adonet/ef/how-to-execute-a-polymorphic-query.md
index 26216e2f5105c..f3f183733b47e 100644
--- a/docs/framework/data/adonet/ef/how-to-execute-a-polymorphic-query.md
+++ b/docs/framework/data/adonet/ef/how-to-execute-a-polymorphic-query.md
@@ -16,7 +16,7 @@ This topic shows how to execute a polymorphic Entity SQL query using the [OFTYPE
1. Add the [School Model](/previous-versions/dotnet/netframework-4.0/bb896300(v=vs.100)) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
[!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
diff --git a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-complex-types.md b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-complex-types.md
index 4f35b6e0d6be3..c2645caf32e34 100644
--- a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-complex-types.md
+++ b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-complex-types.md
@@ -15,7 +15,7 @@ This topic shows how to execute an Entity SQL query that returns entity type obj
1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
[!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
diff --git a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-nested-collections.md b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-nested-collections.md
index 65b88e9774bde..8d281efcd5373 100644
--- a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-nested-collections.md
+++ b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-nested-collections.md
@@ -2,31 +2,31 @@
description: "Learn more about: How to: Execute a Query that Returns Nested Collections"
title: "How to: Execute a Query that Returns Nested Collections"
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
ms.assetid: f7f385f3-ffcf-4f3b-af35-de8818938e5f
---
# How to: Execute a Query that Returns Nested Collections
-This shows how to execute a command against a conceptual model by using an object, and how to retrieve the nested collection results by using an .
-
-### To run the code in this example
-
-1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
-
+This shows how to execute a command against a conceptual model by using an object, and how to retrieve the nested collection results by using an .
+
+### To run the code in this example
+
+1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
+
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
+
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
- [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
-
-## Example
+ [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
+
+## Example
+
+ A *nested collection* is a collection that is inside another collection. The following code retrieves a collection of `Contacts` and the nested collections of `SalesOrderHeaders` that are associated with each `Contact`.
- A *nested collection* is a collection that is inside another collection. The following code retrieves a collection of `Contacts` and the nested collections of `SalesOrderHeaders` that are associated with each `Contact`.
-
[!code-csharp[DP EntityServices Concepts#ReturnNestedCollectionWithEntityCommand](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#returnnestedcollectionwithentitycommand)]
- [!code-vb[DP EntityServices Concepts#ReturnNestedCollectionWithEntityCommand](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#returnnestedcollectionwithentitycommand)]
-
+ [!code-vb[DP EntityServices Concepts#ReturnNestedCollectionWithEntityCommand](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#returnnestedcollectionwithentitycommand)]
+
## See also
- [EntityClient Provider for the Entity Framework](entityclient-provider-for-the-entity-framework.md)
diff --git a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-primitivetype-results.md b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-primitivetype-results.md
index 858adabc18057..4c82a9f95b348 100644
--- a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-primitivetype-results.md
+++ b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-primitivetype-results.md
@@ -2,37 +2,37 @@
description: "Learn more about: How to: Execute a Query that Returns PrimitiveType Results"
title: "How to: Execute a Query that Returns PrimitiveType Results"
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
ms.assetid: 7139d585-4034-4dfa-916f-2120a8b72792
---
# How to: Execute a Query that Returns PrimitiveType Results
-This topic shows how to execute a command against a conceptual model by using an , and how to retrieve the results by using an .
-
-### To run the code in this example
-
-1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
-
+This topic shows how to execute a command against a conceptual model by using an , and how to retrieve the results by using an .
+
+### To run the code in this example
+
+1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
+
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
+
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
- [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
-
-## Example
-
- This example executes a query that returns a result. If you pass the following query as an argument to the `ExecutePrimitiveTypeQuery` function, the function displays the average list price of all `Products`:
-
- [!code-csharp[DP EntityServices Concepts 2#EDM_AVG](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#edm_avg)]
-
- If you pass a parameterized query, like the following, objects to the property on the object.
-
- [!code-csharp[DP EntityServices Concepts 2#CASE_WHEN_THEN_ELSE](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#case_when_then_else)]
-
+ [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
+
+## Example
+
+ This example executes a query that returns a result. If you pass the following query as an argument to the `ExecutePrimitiveTypeQuery` function, the function displays the average list price of all `Products`:
+
+ [!code-csharp[DP EntityServices Concepts 2#EDM_AVG](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#edm_avg)]
+
+ If you pass a parameterized query, like the following, objects to the property on the object.
+
+ [!code-csharp[DP EntityServices Concepts 2#CASE_WHEN_THEN_ELSE](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#case_when_then_else)]
+
[!code-csharp[DP EntityServices Concepts#eSQLPrimitiveTypes](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#esqlprimitivetypes)]
- [!code-vb[DP EntityServices Concepts#eSQLPrimitiveTypes](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#esqlprimitivetypes)]
-
+ [!code-vb[DP EntityServices Concepts#eSQLPrimitiveTypes](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#esqlprimitivetypes)]
+
## See also
- [Entity SQL Reference](./language-reference/entity-sql-reference.md)
diff --git a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-reftype-results.md b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-reftype-results.md
index 881ad5717be49..5b481e5a2a0d1 100644
--- a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-reftype-results.md
+++ b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-reftype-results.md
@@ -2,37 +2,37 @@
description: "Learn more about: How to: Execute a Query that Returns RefType Results"
title: "How to: Execute a Query that Returns RefType Results"
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
ms.assetid: 7dbbfbcd-93f5-4546-9dbf-e5fa290b69fa
---
# How to: Execute a Query that Returns RefType Results
-This topic shows how to execute a command against a conceptual model by using an object, and how to retrieve the results by using an .
-
-### To run the code in this example
-
-1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
-
+This topic shows how to execute a command against a conceptual model by using an object, and how to retrieve the results by using an .
+
+### To run the code in this example
+
+1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
+
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
+
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
- [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
-
-## Example
-
- This example executes a query that returns results. If you pass the following query as an argument to the `ExecuteRefTypeQuery` function, the function returns a reference to the entity:
-
- [!code-csharp[DP EntityServices Concepts 2#REF2](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#ref2)]
-
- If you pass a parameterized query, like the following, add the objects to the property on the object.
-
- [!code-csharp[DP EntityServices Concepts 2#REF3](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#ref3)]
-
+ [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
+
+## Example
+
+ This example executes a query that returns results. If you pass the following query as an argument to the `ExecuteRefTypeQuery` function, the function returns a reference to the entity:
+
+ [!code-csharp[DP EntityServices Concepts 2#REF2](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#ref2)]
+
+ If you pass a parameterized query, like the following, add the objects to the property on the object.
+
+ [!code-csharp[DP EntityServices Concepts 2#REF3](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#ref3)]
+
[!code-csharp[DP EntityServices Concepts#eSQLRefTypes](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#esqlreftypes)]
- [!code-vb[DP EntityServices Concepts#eSQLRefTypes](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#esqlreftypes)]
-
+ [!code-vb[DP EntityServices Concepts#eSQLRefTypes](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#esqlreftypes)]
+
## See also
- [Entity SQL Reference](./language-reference/entity-sql-reference.md)
diff --git a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-structuraltype-results.md b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-structuraltype-results.md
index 230ced2641428..3131f0cf638ef 100644
--- a/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-structuraltype-results.md
+++ b/docs/framework/data/adonet/ef/how-to-execute-a-query-that-returns-structuraltype-results.md
@@ -2,37 +2,37 @@
description: "Learn more about: How to: Execute a Query that Returns StructuralType Results"
title: "How to: Execute a Query that Returns StructuralType Results"
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
ms.assetid: 2314f2a2-b1c3-40c4-95bb-cdf9b21a7b53
---
# How to: Execute a Query that Returns StructuralType Results
-This topic shows how to execute a command against a conceptual model by using an object, and how to retrieve the results by using an . The , and classes derive from the class.
-
-### To run the code in this example
-
-1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
-
+This topic shows how to execute a command against a conceptual model by using an object, and how to retrieve the results by using an . The , and classes derive from the class.
+
+### To run the code in this example
+
+1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
+
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
+
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
- [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
-
-## Example
-
- This example executes a query that returns results. If you pass the following query as an argument to the `ExecuteStructuralTypeQuery` function, the function displays details about the `Products`:
-
- [!code-csharp[DP EntityServices Concepts 2#SelectProduct](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#selectproduct)]
-
- If you pass a parameterized query, like the following, add the objects to the property on the object.
-
- [!code-csharp[DP EntityServices Concepts 2#GREATER_OR_EQUALS](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#greater_or_equals)]
-
+ [!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
+
+## Example
+
+ This example executes a query that returns results. If you pass the following query as an argument to the `ExecuteStructuralTypeQuery` function, the function displays details about the `Products`:
+
+ [!code-csharp[DP EntityServices Concepts 2#SelectProduct](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#selectproduct)]
+
+ If you pass a parameterized query, like the following, add the objects to the property on the object.
+
+ [!code-csharp[DP EntityServices Concepts 2#GREATER_OR_EQUALS](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts 2/cs/entitysql.cs#greater_or_equals)]
+
[!code-csharp[DP EntityServices Concepts#eSQLStructuralTypes](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#esqlstructuraltypes)]
- [!code-vb[DP EntityServices Concepts#eSQLStructuralTypes](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#esqlstructuraltypes)]
-
+ [!code-vb[DP EntityServices Concepts#eSQLStructuralTypes](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#esqlstructuraltypes)]
+
## See also
- [Entity SQL Reference](./language-reference/entity-sql-reference.md)
diff --git a/docs/framework/data/adonet/ef/how-to-navigate-relationships-with-the-navigate-operator.md b/docs/framework/data/adonet/ef/how-to-navigate-relationships-with-the-navigate-operator.md
index c81fd5c8072c4..2622217aa6fa0 100644
--- a/docs/framework/data/adonet/ef/how-to-navigate-relationships-with-the-navigate-operator.md
+++ b/docs/framework/data/adonet/ef/how-to-navigate-relationships-with-the-navigate-operator.md
@@ -15,7 +15,7 @@ This topic shows how to execute a command against a conceptual model by using an
1. Add the [AdventureWorks Sales Model](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) to your project and configure your project to use the Entity Framework. For more information, see [How to: Use the Entity Data Model Wizard](/previous-versions/dotnet/netframework-4.0/bb738677(v=vs.100)).
-2. In the code page for your application, add the following `using` statements (`Imports` in Visual Basic):
+2. In the code page for your application, add the following `using` directives (`Imports` in Visual Basic):
[!code-csharp[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/csharp/VS_Snippets_Data/dp entityservices concepts/cs/source.cs#namespaces)]
[!code-vb[DP EntityServices Concepts#Namespaces](../../../../../samples/snippets/visualbasic/VS_Snippets_Data/dp entityservices concepts/vb/source.vb#namespaces)]
diff --git a/docs/framework/data/adonet/establishing-the-connection.md b/docs/framework/data/adonet/establishing-the-connection.md
index 9ad71993648ca..ab772ed61a180 100644
--- a/docs/framework/data/adonet/establishing-the-connection.md
+++ b/docs/framework/data/adonet/establishing-the-connection.md
@@ -2,149 +2,149 @@
description: "Learn more about: Establishing the Connection"
title: "Establishing the Connection"
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
ms.assetid: 3af512f3-87d9-4005-9e2f-abb1060ff43f
---
# Establishing the Connection
-To connect to Microsoft SQL Server, use the object of the .NET Framework Data Provider for SQL Server. To connect to an OLE DB data source, use the object of the .NET Framework Data Provider for OLE DB. To connect to an ODBC data source, use the object of the .NET Framework Data Provider for ODBC. To connect to an Oracle data source, use the object of the .NET Framework Data Provider for Oracle. For securely storing and retrieving connection strings, see [Protecting Connection Information](protecting-connection-information.md).
-
-## Closing Connections
+To connect to Microsoft SQL Server, use the object of the .NET Framework Data Provider for SQL Server. To connect to an OLE DB data source, use the object of the .NET Framework Data Provider for OLE DB. To connect to an ODBC data source, use the object of the .NET Framework Data Provider for ODBC. To connect to an Oracle data source, use the object of the .NET Framework Data Provider for Oracle. For securely storing and retrieving connection strings, see [Protecting Connection Information](protecting-connection-information.md).
+
+## Closing Connections
+
+ We recommend that you always close the connection when you are finished using it, so that the connection can be returned to the pool. The `Using` block in Visual Basic or C# automatically disposes of the connection when the code exits the block, even in the case of an unhandled exception. See [`using` statement](../../../csharp/language-reference/statements/using.md) and [`Using` Statement](../../../visual-basic/language-reference/statements/using-statement.md) for more information.
+
+ You can also use the `Close` or `Dispose` methods of the connection object for the provider that you are using. Connections that are not explicitly closed might not be added or returned to the pool. For example, a connection that has gone out of scope but that has not been explicitly closed will only be returned to the connection pool if the maximum pool size has been reached and the connection is still valid. For more information, see [OLE DB, ODBC, and Oracle Connection Pooling](ole-db-odbc-and-oracle-connection-pooling.md).
- We recommend that you always close the connection when you are finished using it, so that the connection can be returned to the pool. The `Using` block in Visual Basic or C# automatically disposes of the connection when the code exits the block, even in the case of an unhandled exception. See [using statement](../../../csharp/language-reference/statements/using.md) and [Using Statement](../../../visual-basic/language-reference/statements/using-statement.md) for more information.
-
- You can also use the `Close` or `Dispose` methods of the connection object for the provider that you are using. Connections that are not explicitly closed might not be added or returned to the pool. For example, a connection that has gone out of scope but that has not been explicitly closed will only be returned to the connection pool if the maximum pool size has been reached and the connection is still valid. For more information, see [OLE DB, ODBC, and Oracle Connection Pooling](ole-db-odbc-and-oracle-connection-pooling.md).
-
> [!NOTE]
-> Do not call `Close` or `Dispose` on a **Connection**, a **DataReader**, or any other managed object in the `Finalize` method of your class. In a finalizer, only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a `Finalize` method in your class definition. For more information, see [Garbage Collection](../../../standard/garbage-collection/index.md).
-
+> Do not call `Close` or `Dispose` on a **Connection**, a **DataReader**, or any other managed object in the `Finalize` method of your class. In a finalizer, only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a `Finalize` method in your class definition. For more information, see [Garbage Collection](../../../standard/garbage-collection/index.md).
+
> [!NOTE]
-> Login and logout events will not be raised on the server when a connection is fetched from or returned to the connection pool, because the connection is not actually closed when it is returned to the connection pool. For more information, see [SQL Server Connection Pooling (ADO.NET)](sql-server-connection-pooling.md).
-
-## Connecting to SQL Server
-
- The .NET Framework Data Provider for SQL Server supports a connection string format that is similar to the OLE DB (ADO) connection string format. For valid string format names and values, see the property of the object. You can also use the class to create syntactically valid connection strings at run time. For more information, see [Connection String Builders](connection-string-builders.md).
-
- The following code example demonstrates how to create and open a connection to a SQL Server database.
-
-```vb
-' Assumes connectionString is a valid connection string.
-Using connection As New SqlConnection(connectionString)
- connection.Open()
- ' Do work here.
-End Using
-```
-
-```csharp
-// Assumes connectionString is a valid connection string.
-using (SqlConnection connection = new SqlConnection(connectionString))
-{
- connection.Open();
- // Do work here.
-}
-```
-
-### Integrated Security and ASP.NET
-
- SQL Server integrated security (also known as trusted connections) helps to provide protection when connecting to SQL Server as it does not expose a user ID and password in the connection string and is the recommended method for authenticating a connection. Integrated security uses the current security identity, or token, of the executing process. For desktop applications, this is typically the identity of the currently logged-on user.
-
- The security identity for ASP.NET applications can be set to one of several different options. To better understand the security identity that an ASP.NET application uses when connecting to SQL Server, see [ASP.NET Impersonation](/previous-versions/aspnet/xh507fc5(v=vs.100)), [ASP.NET Authentication](/previous-versions/aspnet/eeyk640h(v=vs.100)), and [How to: Access SQL Server Using Windows Integrated Security](/previous-versions/aspnet/bsz5788z(v=vs.100)).
-
-## Connecting to an OLE DB Data Source
-
- The .NET Framework Data Provider for OLE DB provides connectivity to data sources exposed using OLE DB (through SQLOLEDB, the OLE DB Provider for SQL Server), using the **OleDbConnection** object.
-
- For the .NET Framework Data Provider for OLE DB, the connection string format is identical to the connection string format used in ADO, with the following exceptions:
-
-- The **Provider** keyword is required.
-
-- The **URL**, **Remote Provider**, and **Remote Server** keywords are not supported.
-
- For more information about OLE DB connection strings, see the topic. You can also use the to create connection strings at run time.
-
+> Login and logout events will not be raised on the server when a connection is fetched from or returned to the connection pool, because the connection is not actually closed when it is returned to the connection pool. For more information, see [SQL Server Connection Pooling (ADO.NET)](sql-server-connection-pooling.md).
+
+## Connecting to SQL Server
+
+ The .NET Framework Data Provider for SQL Server supports a connection string format that is similar to the OLE DB (ADO) connection string format. For valid string format names and values, see the property of the object. You can also use the class to create syntactically valid connection strings at run time. For more information, see [Connection String Builders](connection-string-builders.md).
+
+ The following code example demonstrates how to create and open a connection to a SQL Server database.
+
+```vb
+' Assumes connectionString is a valid connection string.
+Using connection As New SqlConnection(connectionString)
+ connection.Open()
+ ' Do work here.
+End Using
+```
+
+```csharp
+// Assumes connectionString is a valid connection string.
+using (SqlConnection connection = new SqlConnection(connectionString))
+{
+ connection.Open();
+ // Do work here.
+}
+```
+
+### Integrated Security and ASP.NET
+
+ SQL Server integrated security (also known as trusted connections) helps to provide protection when connecting to SQL Server as it does not expose a user ID and password in the connection string and is the recommended method for authenticating a connection. Integrated security uses the current security identity, or token, of the executing process. For desktop applications, this is typically the identity of the currently logged-on user.
+
+ The security identity for ASP.NET applications can be set to one of several different options. To better understand the security identity that an ASP.NET application uses when connecting to SQL Server, see [ASP.NET Impersonation](/previous-versions/aspnet/xh507fc5(v=vs.100)), [ASP.NET Authentication](/previous-versions/aspnet/eeyk640h(v=vs.100)), and [How to: Access SQL Server Using Windows Integrated Security](/previous-versions/aspnet/bsz5788z(v=vs.100)).
+
+## Connecting to an OLE DB Data Source
+
+ The .NET Framework Data Provider for OLE DB provides connectivity to data sources exposed using OLE DB (through SQLOLEDB, the OLE DB Provider for SQL Server), using the **OleDbConnection** object.
+
+ For the .NET Framework Data Provider for OLE DB, the connection string format is identical to the connection string format used in ADO, with the following exceptions:
+
+- The **Provider** keyword is required.
+
+- The **URL**, **Remote Provider**, and **Remote Server** keywords are not supported.
+
+ For more information about OLE DB connection strings, see the topic. You can also use the to create connection strings at run time.
+
> [!NOTE]
-> The **OleDbConnection** object does not support setting or retrieving dynamic properties specific to an OLE DB provider. Only properties that can be passed in the connection string for the OLE DB provider are supported.
-
- The following code example demonstrates how to create and open a connection to an OLE DB data source.
-
-```vb
-' Assumes connectionString is a valid connection string.
-Using connection As New OleDbConnection(connectionString)
- connection.Open()
- ' Do work here.
-End Using
-```
-
-```csharp
-// Assumes connectionString is a valid connection string.
+> The **OleDbConnection** object does not support setting or retrieving dynamic properties specific to an OLE DB provider. Only properties that can be passed in the connection string for the OLE DB provider are supported.
+
+ The following code example demonstrates how to create and open a connection to an OLE DB data source.
+
+```vb
+' Assumes connectionString is a valid connection string.
+Using connection As New OleDbConnection(connectionString)
+ connection.Open()
+ ' Do work here.
+End Using
+```
+
+```csharp
+// Assumes connectionString is a valid connection string.
using (OleDbConnection connection =
- new OleDbConnection(connectionString))
-{
- connection.Open();
- // Do work here.
-}
-```
-
-## Do Not Use Universal Data Link Files
-
- It is possible to supply connection information for an **OleDbConnection** in a Universal Data Link (UDL) file; however you should avoid doing so. UDL files are not encrypted, and expose connection string information in clear text. Because a UDL file is an external file-based resource to your application, it cannot be secured using the .NET Framework.
-
-## Connecting to an ODBC Data Source
-
- The .NET Framework Data Provider for ODBC provides connectivity to data sources exposed using ODBC using the **OdbcConnection** object.
-
- For the .NET Framework Data Provider for ODBC, the connection string format is designed to match the ODBC connection string format as closely as possible. You may also supply an ODBC data source name (DSN). For more detail on the **OdbcConnection** , see the .
-
- The following code example demonstrates how to create and open a connection to an ODBC data source.
-
-```vb
-' Assumes connectionString is a valid connection string.
-Using connection As New OdbcConnection(connectionString)
- connection.Open()
- ' Do work here.
-End Using
-```
-
-```csharp
-// Assumes connectionString is a valid connection string.
+ new OleDbConnection(connectionString))
+{
+ connection.Open();
+ // Do work here.
+}
+```
+
+## Do Not Use Universal Data Link Files
+
+ It is possible to supply connection information for an **OleDbConnection** in a Universal Data Link (UDL) file; however you should avoid doing so. UDL files are not encrypted, and expose connection string information in clear text. Because a UDL file is an external file-based resource to your application, it cannot be secured using the .NET Framework.
+
+## Connecting to an ODBC Data Source
+
+ The .NET Framework Data Provider for ODBC provides connectivity to data sources exposed using ODBC using the **OdbcConnection** object.
+
+ For the .NET Framework Data Provider for ODBC, the connection string format is designed to match the ODBC connection string format as closely as possible. You may also supply an ODBC data source name (DSN). For more detail on the **OdbcConnection** , see the .
+
+ The following code example demonstrates how to create and open a connection to an ODBC data source.
+
+```vb
+' Assumes connectionString is a valid connection string.
+Using connection As New OdbcConnection(connectionString)
+ connection.Open()
+ ' Do work here.
+End Using
+```
+
+```csharp
+// Assumes connectionString is a valid connection string.
using (OdbcConnection connection =
- new OdbcConnection(connectionString))
-{
- connection.Open();
- // Do work here.
-}
-```
-
-## Connecting to an Oracle Data Source
-
- The .NET Framework Data Provider for Oracle provides connectivity to Oracle data sources using the **OracleConnection** object.
-
- For the .NET Framework Data Provider for Oracle, the connection string format is designed to match the OLE DB Provider for Oracle (MSDAORA) connection string format as closely as possible. For more detail on the **OracleConnection**, see the .
-
- The following code example demonstrates how to create and open a connection to an Oracle data source.
-
-```vb
-' Assumes connectionString is a valid connection string.
-Using connection As New OracleConnection(connectionString)
- connection.Open()
- ' Do work here.
-End Using
-```
-
-```csharp
-// Assumes connectionString is a valid connection string.
+ new OdbcConnection(connectionString))
+{
+ connection.Open();
+ // Do work here.
+}
+```
+
+## Connecting to an Oracle Data Source
+
+ The .NET Framework Data Provider for Oracle provides connectivity to Oracle data sources using the **OracleConnection** object.
+
+ For the .NET Framework Data Provider for Oracle, the connection string format is designed to match the OLE DB Provider for Oracle (MSDAORA) connection string format as closely as possible. For more detail on the **OracleConnection**, see the .
+
+ The following code example demonstrates how to create and open a connection to an Oracle data source.
+
+```vb
+' Assumes connectionString is a valid connection string.
+Using connection As New OracleConnection(connectionString)
+ connection.Open()
+ ' Do work here.
+End Using
+```
+
+```csharp
+// Assumes connectionString is a valid connection string.
using (OracleConnection connection =
- new OracleConnection(connectionString))
-{
- connection.Open();
- // Do work here.
-}
-OracleConnection nwindConn = new OracleConnection("Data Source=MyOracleServer;Integrated Security=yes;");
-nwindConn.Open();
-```
-
+ new OracleConnection(connectionString))
+{
+ connection.Open();
+ // Do work here.
+}
+OracleConnection nwindConn = new OracleConnection("Data Source=MyOracleServer;Integrated Security=yes;");
+nwindConn.Open();
+```
+
## See also
- [Connecting to a Data Source](connecting-to-a-data-source.md)
diff --git a/docs/framework/data/adonet/sql/aspnet-apps-using-wait-handles.md b/docs/framework/data/adonet/sql/aspnet-apps-using-wait-handles.md
index eeae161fe5dcc..779a1311b21f2 100644
--- a/docs/framework/data/adonet/sql/aspnet-apps-using-wait-handles.md
+++ b/docs/framework/data/adonet/sql/aspnet-apps-using-wait-handles.md
@@ -2,581 +2,581 @@
description: "Learn more about: ASP.NET Applications Using Wait Handles"
title: "ASP.NET Applications Using Wait Handles"
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
ms.assetid: f588597a-49de-4206-8463-4ef377e112ff
---
# ASP.NET Applications Using Wait Handles
-The callback and polling models for handling asynchronous operations are useful when your application is processing only one asynchronous operation at a time. The Wait models provide a more flexible way of processing multiple asynchronous operations. There are two Wait models, named for the methods used to implement them: the Wait (Any) model and the Wait (All) model.
-
- To use either Wait model, you need to use the property of the object returned by the , , or methods. The and methods both require you to send the objects as an argument, grouped together in an array.
-
- Both Wait methods monitor the asynchronous operations, waiting for completion. The method waits for any of the operations to complete or time out. Once you know a particular operation is complete, you can process its results and then continue waiting for the next operation to complete or time out. The method waits for all of the processes in the array of instances to complete or time out before continuing.
-
- The Wait models' benefit is most striking when you need to run multiple operations of some length on different servers, or when your server is powerful enough to process all the queries at the same time. In the examples presented here, three queries emulate long processes by adding WAITFOR commands of varying lengths to inconsequential SELECT queries.
-
-## Example: Wait (Any) Model
-
- The following example illustrates the Wait (Any) model. Once three asynchronous processes are started, the method is called to wait for the completion of any one of them. As each process completes, the method is called and the resulting object is read. At this point, a real-world application would likely use the to populate a portion of the page. In this simple example, the time the process completed is added to a text box corresponding to the process. Taken together, the times in the text boxes illustrate the point: Code is executed each time a process completes.
-
- To set up this example, create a new ASP.NET Web Site project. Place a control and four controls on the page (accepting the default name for each control).
-
- Add the following code to the form's class, modifying the connection string as necessary for your environment.
-
-```vb
-' Add these to the top of the class
-Imports System
-Imports System.Data
-Imports System.Data.SqlClient
-Imports System.Threading
-
-' Add this code to the page's class:
- Private Function GetConnectionString() As String
+The callback and polling models for handling asynchronous operations are useful when your application is processing only one asynchronous operation at a time. The Wait models provide a more flexible way of processing multiple asynchronous operations. There are two Wait models, named for the methods used to implement them: the Wait (Any) model and the Wait (All) model.
+
+ To use either Wait model, you need to use the property of the object returned by the , , or methods. The and methods both require you to send the objects as an argument, grouped together in an array.
+
+ Both Wait methods monitor the asynchronous operations, waiting for completion. The method waits for any of the operations to complete or time out. Once you know a particular operation is complete, you can process its results and then continue waiting for the next operation to complete or time out. The method waits for all of the processes in the array of instances to complete or time out before continuing.
+
+ The Wait models' benefit is most striking when you need to run multiple operations of some length on different servers, or when your server is powerful enough to process all the queries at the same time. In the examples presented here, three queries emulate long processes by adding WAITFOR commands of varying lengths to inconsequential SELECT queries.
+
+## Example: Wait (Any) Model
+
+ The following example illustrates the Wait (Any) model. Once three asynchronous processes are started, the method is called to wait for the completion of any one of them. As each process completes, the method is called and the resulting object is read. At this point, a real-world application would likely use the to populate a portion of the page. In this simple example, the time the process completed is added to a text box corresponding to the process. Taken together, the times in the text boxes illustrate the point: Code is executed each time a process completes.
+
+ To set up this example, create a new ASP.NET Web Site project. Place a control and four controls on the page (accepting the default name for each control).
+
+ Add the following code to the form's class, modifying the connection string as necessary for your environment.
+
+```vb
+' Add these to the top of the class
+Imports System
+Imports System.Data
+Imports System.Data.SqlClient
+Imports System.Threading
+
+' Add this code to the page's class:
+ Private Function GetConnectionString() As String
' To avoid storing the connection string in your code,
' you can retrieve it from a configuration file.
-
+
' If you have not included "Asynchronous Processing=true"
- ' in the connection string, the command will not be able
- ' to execute asynchronously.
- Return "Data Source=(local);Integrated Security=SSPI;" & _
- "Initial Catalog=AdventureWorks;" & _
- "Asynchronous Processing=true"
+ ' in the connection string, the command will not be able
+ ' to execute asynchronously.
+ Return "Data Source=(local);Integrated Security=SSPI;" & _
+ "Initial Catalog=AdventureWorks;" & _
+ "Asynchronous Processing=true"
End Function
-
- Sub Button1_Click( _
- ByVal sender As Object, ByVal e As System.EventArgs)
-
+
+ Sub Button1_Click( _
+ ByVal sender As Object, ByVal e As System.EventArgs)
+
' In a real-world application, you might be connecting to
- ' three different servers or databases. For the example,
- ' we connect to only one.
- Dim connection1 As New SqlConnection(GetConnectionString())
- Dim connection2 As New SqlConnection(GetConnectionString())
- Dim connection3 As New SqlConnection(GetConnectionString())
-
+ ' three different servers or databases. For the example,
+ ' we connect to only one.
+ Dim connection1 As New SqlConnection(GetConnectionString())
+ Dim connection2 As New SqlConnection(GetConnectionString())
+ Dim connection3 As New SqlConnection(GetConnectionString())
+
' To keep the example simple, all three asynchronous
- ' processes select a row from the same table. WAITFOR
- ' commands are used to emulate long-running processes
- ' that complete after different periods of time.
- Dim commandText1 As String = _
- "WAITFOR DELAY '0:0:01';" & _
- "SELECT * FROM Production.Product " & _
- "WHERE ProductNumber = 'BL-2036'"
-
- Dim commandText2 As String = _
- "WAITFOR DELAY '0:0:05';" & _
- "SELECT * FROM Production.Product " & _
- "WHERE ProductNumber = 'BL-2036'"
-
- Dim commandText3 As String = _
- "WAITFOR DELAY '0:0:10';" & _
- "SELECT * FROM Production.Product " & _
- "WHERE ProductNumber = 'BL-2036'"
-
- Dim waitHandles(2) As WaitHandle
- Try
- ' For each process, open a connection and begin execution.
+ ' processes select a row from the same table. WAITFOR
+ ' commands are used to emulate long-running processes
+ ' that complete after different periods of time.
+ Dim commandText1 As String = _
+ "WAITFOR DELAY '0:0:01';" & _
+ "SELECT * FROM Production.Product " & _
+ "WHERE ProductNumber = 'BL-2036'"
+
+ Dim commandText2 As String = _
+ "WAITFOR DELAY '0:0:05';" & _
+ "SELECT * FROM Production.Product " & _
+ "WHERE ProductNumber = 'BL-2036'"
+
+ Dim commandText3 As String = _
+ "WAITFOR DELAY '0:0:10';" & _
+ "SELECT * FROM Production.Product " & _
+ "WHERE ProductNumber = 'BL-2036'"
+
+ Dim waitHandles(2) As WaitHandle
+ Try
+ ' For each process, open a connection and begin execution.
' Use the IAsyncResult object returned by
- ' BeginExecuteReader to add a WaitHandle for the process
- ' to the array.
- connection1.Open()
- Dim command1 As New SqlCommand(commandText1, connection1)
- Dim result1 As IAsyncResult = _
- command1.BeginExecuteReader()
- waitHandles(0) = result1.AsyncWaitHandle
-
- connection2.Open()
- Dim command2 As New SqlCommand(commandText2, connection2)
- Dim result2 As IAsyncResult = _
- command2.BeginExecuteReader()
- waitHandles(1) = result2.AsyncWaitHandle
-
- connection3.Open()
- Dim command3 As New SqlCommand(commandText3, connection3)
- Dim result3 As IAsyncResult = _
- command3.BeginExecuteReader()
- waitHandles(2) = result3.AsyncWaitHandle
-
- Dim index As Integer
- For countWaits As Integer = 1 To 3
- ' WaitAny waits for any of the processes to complete.
- ' The return value is either the index of the
- ' array element whose process just completed, or
- ' the WaitTimeout value.
- index = WaitHandle.WaitAny(waitHandles, 60000, False)
+ ' BeginExecuteReader to add a WaitHandle for the process
+ ' to the array.
+ connection1.Open()
+ Dim command1 As New SqlCommand(commandText1, connection1)
+ Dim result1 As IAsyncResult = _
+ command1.BeginExecuteReader()
+ waitHandles(0) = result1.AsyncWaitHandle
+
+ connection2.Open()
+ Dim command2 As New SqlCommand(commandText2, connection2)
+ Dim result2 As IAsyncResult = _
+ command2.BeginExecuteReader()
+ waitHandles(1) = result2.AsyncWaitHandle
+
+ connection3.Open()
+ Dim command3 As New SqlCommand(commandText3, connection3)
+ Dim result3 As IAsyncResult = _
+ command3.BeginExecuteReader()
+ waitHandles(2) = result3.AsyncWaitHandle
+
+ Dim index As Integer
+ For countWaits As Integer = 1 To 3
+ ' WaitAny waits for any of the processes to complete.
+ ' The return value is either the index of the
+ ' array element whose process just completed, or
+ ' the WaitTimeout value.
+ index = WaitHandle.WaitAny(waitHandles, 60000, False)
' This example doesn't actually do anything with the
' data returned by the processes, but the code opens
- ' readers for each just to demonstrate the concept.
+ ' readers for each just to demonstrate the concept.
' Instead of using the returned data to fill the
- ' controls on the page, the example adds the time
- ' the process was completed to the corresponding
- ' text box.
- Select Case index
- Case 0
- Dim reader1 As SqlDataReader
- reader1 = command1.EndExecuteReader(result1)
- If reader1.Read Then
- TextBox1.Text = _
- "Completed " & _
- System.DateTime.Now.ToLongTimeString()
- End If
- reader1.Close()
-
- Case 1
- Dim reader2 As SqlDataReader
- reader2 = command2.EndExecuteReader(result2)
- If reader2.Read Then
- TextBox2.Text = _
- "Completed " & _
- System.DateTime.Now.ToLongTimeString()
- End If
- reader2.Close()
- Case 2
- Dim reader3 As SqlDataReader
- reader3 = command3.EndExecuteReader(result3)
- If reader3.Read Then
- TextBox3.Text = _
- "Completed " & _
- System.DateTime.Now.ToLongTimeString()
- End If
- reader3.Close()
- Case WaitHandle.WaitTimeout
- Throw New Exception("Timeout")
- End Select
-
- Next
- Catch ex As Exception
- TextBox4.Text = ex.ToString
- End Try
- connection1.Close()
- connection2.Close()
- connection3.Close()
-
- End Sub
-```
-
-```csharp
-// Add the following using statements, if they are not already there.
-using System;
-using System.Data;
-using System.Configuration;
-using System.Web;
-using System.Web.Security;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using System.Web.UI.WebControls.WebParts;
-using System.Web.UI.HtmlControls;
-using System.Threading;
-using System.Data.SqlClient;
-
-// Add this code to the page's class
-string GetConnectionString()
+ ' controls on the page, the example adds the time
+ ' the process was completed to the corresponding
+ ' text box.
+ Select Case index
+ Case 0
+ Dim reader1 As SqlDataReader
+ reader1 = command1.EndExecuteReader(result1)
+ If reader1.Read Then
+ TextBox1.Text = _
+ "Completed " & _
+ System.DateTime.Now.ToLongTimeString()
+ End If
+ reader1.Close()
+
+ Case 1
+ Dim reader2 As SqlDataReader
+ reader2 = command2.EndExecuteReader(result2)
+ If reader2.Read Then
+ TextBox2.Text = _
+ "Completed " & _
+ System.DateTime.Now.ToLongTimeString()
+ End If
+ reader2.Close()
+ Case 2
+ Dim reader3 As SqlDataReader
+ reader3 = command3.EndExecuteReader(result3)
+ If reader3.Read Then
+ TextBox3.Text = _
+ "Completed " & _
+ System.DateTime.Now.ToLongTimeString()
+ End If
+ reader3.Close()
+ Case WaitHandle.WaitTimeout
+ Throw New Exception("Timeout")
+ End Select
+
+ Next
+ Catch ex As Exception
+ TextBox4.Text = ex.ToString
+ End Try
+ connection1.Close()
+ connection2.Close()
+ connection3.Close()
+
+ End Sub
+```
+
+```csharp
+// Add the following using directives, if they aren't already there.
+using System;
+using System.Data;
+using System.Configuration;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+using System.Threading;
+using System.Data.SqlClient;
+
+// Add this code to the page's class
+string GetConnectionString()
// To avoid storing the connection string in your code,
// you can retrieve it from a configuration file.
// If you have not included "Asynchronous Processing=true"
- // in the connection string, the command will not be able
- // to execute asynchronously.
-{
- return "Data Source=(local);Integrated Security=SSPI;" +
- "Initial Catalog=AdventureWorks;" +
- "Asynchronous Processing=true";
-}
-void Button1_Click(object sender, System.EventArgs e)
-{
+ // in the connection string, the command will not be able
+ // to execute asynchronously.
+{
+ return "Data Source=(local);Integrated Security=SSPI;" +
+ "Initial Catalog=AdventureWorks;" +
+ "Asynchronous Processing=true";
+}
+void Button1_Click(object sender, System.EventArgs e)
+{
// In a real-world application, you might be connecting to
- // three different servers or databases. For the example,
- // we connect to only one.
-
+ // three different servers or databases. For the example,
+ // we connect to only one.
+
SqlConnection connection1 =
- new SqlConnection(GetConnectionString());
+ new SqlConnection(GetConnectionString());
SqlConnection connection2 =
- new SqlConnection(GetConnectionString());
+ new SqlConnection(GetConnectionString());
SqlConnection connection3 =
- new SqlConnection(GetConnectionString());
+ new SqlConnection(GetConnectionString());
// To keep the example simple, all three asynchronous
- // processes select a row from the same table. WAITFOR
- // commands are used to emulate long-running processes
- // that complete after different periods of time.
-
+ // processes select a row from the same table. WAITFOR
+ // commands are used to emulate long-running processes
+ // that complete after different periods of time.
+
string commandText1 = "WAITFOR DELAY '0:0:01';" +
"SELECT * FROM Production.Product " +
- "WHERE ProductNumber = 'BL-2036'";
+ "WHERE ProductNumber = 'BL-2036'";
string commandText2 = "WAITFOR DELAY '0:0:05';" +
"SELECT * FROM Production.Product " +
- "WHERE ProductNumber = 'BL-2036'";
+ "WHERE ProductNumber = 'BL-2036'";
string commandText3 = "WAITFOR DELAY '0:0:10';" +
"SELECT * FROM Production.Product " +
- "WHERE ProductNumber = 'BL-2036'";
- try
+ "WHERE ProductNumber = 'BL-2036'";
+ try
// For each process, open a connection and begin
// execution. Use the IAsyncResult object returned by
// BeginExecuteReader to add a WaitHandle for the
- // process to the array.
- {
- connection1.Open();
- SqlCommand command1 =
- new SqlCommand(commandText1, connection1);
- IAsyncResult result1 = command1.BeginExecuteReader();
- WaitHandle waitHandle1 = result1.AsyncWaitHandle;
-
- connection2.Open();
- SqlCommand command2 =
- new SqlCommand(commandText2, connection2);
- IAsyncResult result2 = command2.BeginExecuteReader();
- WaitHandle waitHandle2 = result2.AsyncWaitHandle;
-
- connection3.Open();
- SqlCommand command3 =
- new SqlCommand(commandText3, connection3);
- IAsyncResult result3 = command3.BeginExecuteReader();
- WaitHandle waitHandle3 = result3.AsyncWaitHandle;
-
- WaitHandle[] waitHandles = {
- waitHandle1, waitHandle2, waitHandle3
- };
-
- int index;
- for (int countWaits = 0; countWaits <= 2; countWaits++)
- {
+ // process to the array.
+ {
+ connection1.Open();
+ SqlCommand command1 =
+ new SqlCommand(commandText1, connection1);
+ IAsyncResult result1 = command1.BeginExecuteReader();
+ WaitHandle waitHandle1 = result1.AsyncWaitHandle;
+
+ connection2.Open();
+ SqlCommand command2 =
+ new SqlCommand(commandText2, connection2);
+ IAsyncResult result2 = command2.BeginExecuteReader();
+ WaitHandle waitHandle2 = result2.AsyncWaitHandle;
+
+ connection3.Open();
+ SqlCommand command3 =
+ new SqlCommand(commandText3, connection3);
+ IAsyncResult result3 = command3.BeginExecuteReader();
+ WaitHandle waitHandle3 = result3.AsyncWaitHandle;
+
+ WaitHandle[] waitHandles = {
+ waitHandle1, waitHandle2, waitHandle3
+ };
+
+ int index;
+ for (int countWaits = 0; countWaits <= 2; countWaits++)
+ {
// WaitAny waits for any of the processes to
// complete. The return value is either the index
// of the array element whose process just
- // completed, or the WaitTimeout value.
-
+ // completed, or the WaitTimeout value.
+
index = WaitHandle.WaitAny(waitHandles,
- 60000, false);
+ 60000, false);
// This example doesn't actually do anything with
// the data returned by the processes, but the
// code opens readers for each just to demonstrate
- // the concept.
+ // the concept.
// Instead of using the returned data to fill the
- // controls on the page, the example adds the time
- // the process was completed to the corresponding
- // text box.
-
- switch (index)
- {
- case 0:
- SqlDataReader reader1;
+ // controls on the page, the example adds the time
+ // the process was completed to the corresponding
+ // text box.
+
+ switch (index)
+ {
+ case 0:
+ SqlDataReader reader1;
reader1 =
- command1.EndExecuteReader(result1);
- if (reader1.Read())
- {
+ command1.EndExecuteReader(result1);
+ if (reader1.Read())
+ {
TextBox1.Text =
- "Completed " +
- System.DateTime.Now.ToLongTimeString();
- }
- reader1.Close();
- break;
- case 1:
- SqlDataReader reader2;
+ "Completed " +
+ System.DateTime.Now.ToLongTimeString();
+ }
+ reader1.Close();
+ break;
+ case 1:
+ SqlDataReader reader2;
reader2 =
- command2.EndExecuteReader(result2);
- if (reader2.Read())
- {
+ command2.EndExecuteReader(result2);
+ if (reader2.Read())
+ {
TextBox2.Text =
- "Completed " +
- System.DateTime.Now.ToLongTimeString();
- }
- reader2.Close();
- break;
- case 2:
- SqlDataReader reader3;
+ "Completed " +
+ System.DateTime.Now.ToLongTimeString();
+ }
+ reader2.Close();
+ break;
+ case 2:
+ SqlDataReader reader3;
reader3 =
- command3.EndExecuteReader(result3);
- if (reader3.Read())
- {
+ command3.EndExecuteReader(result3);
+ if (reader3.Read())
+ {
TextBox3.Text =
- "Completed " +
- System.DateTime.Now.ToLongTimeString();
- }
- reader3.Close();
- break;
- case WaitHandle.WaitTimeout:
- throw new Exception("Timeout");
- break;
- }
- }
- }
- catch (Exception ex)
- {
- TextBox4.Text = ex.ToString();
- }
- connection1.Close();
- connection2.Close();
- connection3.Close();
-}
-```
-
-## Example: Wait (All) Model
-
- The following example illustrates the Wait (All) model. Once three asynchronous processes are started, the method is called to wait for the processes to complete or time out.
-
- Like the example of the Wait (Any) model, the time the process completed is added to a text box corresponding to the process. Again, the times in the text boxes illustrate the point: Code following the method is executed only after all processes are complete.
-
- To set up this example, create a new ASP.NET Web Site project. Place a control and four controls on the page (accepting the default name for each control).
-
- Add the following code to the form's class, modifying the connection string as necessary for your environment.
-
-```vb
-' Add these to the top of the class
-Imports System
-Imports System.Data
-Imports System.Data.SqlClient
-Imports System.Threading
-
-' Add this code to the page's class:
- Private Function GetConnectionString() As String
+ "Completed " +
+ System.DateTime.Now.ToLongTimeString();
+ }
+ reader3.Close();
+ break;
+ case WaitHandle.WaitTimeout:
+ throw new Exception("Timeout");
+ break;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ TextBox4.Text = ex.ToString();
+ }
+ connection1.Close();
+ connection2.Close();
+ connection3.Close();
+}
+```
+
+## Example: Wait (All) Model
+
+ The following example illustrates the Wait (All) model. Once three asynchronous processes are started, the method is called to wait for the processes to complete or time out.
+
+ Like the example of the Wait (Any) model, the time the process completed is added to a text box corresponding to the process. Again, the times in the text boxes illustrate the point: Code following the method is executed only after all processes are complete.
+
+ To set up this example, create a new ASP.NET Web Site project. Place a control and four controls on the page (accepting the default name for each control).
+
+ Add the following code to the form's class, modifying the connection string as necessary for your environment.
+
+```vb
+' Add these to the top of the class
+Imports System
+Imports System.Data
+Imports System.Data.SqlClient
+Imports System.Threading
+
+' Add this code to the page's class:
+ Private Function GetConnectionString() As String
' To avoid storing the connection string in your code,
' you can retrieve it from a configuration file.
-
+
' If you have not included "Asynchronous Processing=true"
- ' in the connection string, the command will not be able
- ' to execute asynchronously.
- Return "Data Source=(local);Integrated Security=SSPI;" & _
- "Initial Catalog=AdventureWorks;" & _
- "Asynchronous Processing=true"
+ ' in the connection string, the command will not be able
+ ' to execute asynchronously.
+ Return "Data Source=(local);Integrated Security=SSPI;" & _
+ "Initial Catalog=AdventureWorks;" & _
+ "Asynchronous Processing=true"
End Function
- Sub Button1_Click( _
- ByVal sender As Object, ByVal e As System.EventArgs)
-
+ Sub Button1_Click( _
+ ByVal sender As Object, ByVal e As System.EventArgs)
+
' In a real-world application, you might be connecting to
- ' three different servers or databases. For the example,
- ' we connect to only one.
- Dim connection1 As New SqlConnection(GetConnectionString())
- Dim connection2 As New SqlConnection(GetConnectionString())
- Dim connection3 As New SqlConnection(GetConnectionString())
-
+ ' three different servers or databases. For the example,
+ ' we connect to only one.
+ Dim connection1 As New SqlConnection(GetConnectionString())
+ Dim connection2 As New SqlConnection(GetConnectionString())
+ Dim connection3 As New SqlConnection(GetConnectionString())
+
' To keep the example simple, all three asynchronous
- ' processes select a row from the same table. WAITFOR
- ' commands are used to emulate long-running processes
- ' that complete after different periods of time.
- Dim commandText1 As String = _
- "UPDATE Production.Product " & _
- "SET ReorderPoint = ReorderPoint + 1 " & _
- "WHERE ReorderPoint Is Not Null;" & _
- "WAITFOR DELAY '0:0:01';" & _
- "UPDATE Production.Product " & _
- "SET ReorderPoint = ReorderPoint - 1 " & _
- "WHERE ReorderPoint Is Not Null"
-
- Dim commandText2 As String = _
- "UPDATE Production.Product " & _
- "SET ReorderPoint = ReorderPoint + 1 " & _
- "WHERE ReorderPoint Is Not Null;" & _
- "WAITFOR DELAY '0:0:05';" & _
- "UPDATE Production.Product " & _
- "SET ReorderPoint = ReorderPoint - 1 " & _
- "WHERE ReorderPoint Is Not Null"
-
- Dim commandText3 As String = _
- "UPDATE Production.Product " & _
- "SET ReorderPoint = ReorderPoint + 1 " & _
- "WHERE ReorderPoint Is Not Null;" & _
- "WAITFOR DELAY '0:0:10';" & _
- "UPDATE Production.Product " & _
- "SET ReorderPoint = ReorderPoint - 1 " & _
- "WHERE ReorderPoint Is Not Null"
-
- Dim waitHandles(2) As WaitHandle
-
- Try
- ' For each process, open a connection and begin execution.
+ ' processes select a row from the same table. WAITFOR
+ ' commands are used to emulate long-running processes
+ ' that complete after different periods of time.
+ Dim commandText1 As String = _
+ "UPDATE Production.Product " & _
+ "SET ReorderPoint = ReorderPoint + 1 " & _
+ "WHERE ReorderPoint Is Not Null;" & _
+ "WAITFOR DELAY '0:0:01';" & _
+ "UPDATE Production.Product " & _
+ "SET ReorderPoint = ReorderPoint - 1 " & _
+ "WHERE ReorderPoint Is Not Null"
+
+ Dim commandText2 As String = _
+ "UPDATE Production.Product " & _
+ "SET ReorderPoint = ReorderPoint + 1 " & _
+ "WHERE ReorderPoint Is Not Null;" & _
+ "WAITFOR DELAY '0:0:05';" & _
+ "UPDATE Production.Product " & _
+ "SET ReorderPoint = ReorderPoint - 1 " & _
+ "WHERE ReorderPoint Is Not Null"
+
+ Dim commandText3 As String = _
+ "UPDATE Production.Product " & _
+ "SET ReorderPoint = ReorderPoint + 1 " & _
+ "WHERE ReorderPoint Is Not Null;" & _
+ "WAITFOR DELAY '0:0:10';" & _
+ "UPDATE Production.Product " & _
+ "SET ReorderPoint = ReorderPoint - 1 " & _
+ "WHERE ReorderPoint Is Not Null"
+
+ Dim waitHandles(2) As WaitHandle
+
+ Try
+ ' For each process, open a connection and begin execution.
' Use the IAsyncResult object returned by
- ' BeginExecuteReader to add a WaitHandle for the process
- ' to the array.
- connection1.Open()
- Dim command1 As New SqlCommand(commandText1, connection1)
- Dim result1 As IAsyncResult = _
- command1.BeginExecuteNonQuery()
- waitHandles(0) = result1.AsyncWaitHandle
-
- connection2.Open()
- Dim command2 As New SqlCommand(commandText2, connection2)
- Dim result2 As IAsyncResult = _
- command2.BeginExecuteNonQuery()
- waitHandles(1) = result2.AsyncWaitHandle
-
- connection3.Open()
- Dim command3 As New SqlCommand(commandText3, connection3)
- Dim result3 As IAsyncResult = _
- command3.BeginExecuteNonQuery()
- waitHandles(2) = result3.AsyncWaitHandle
-
- ' WaitAll waits for all of the processes to complete.
+ ' BeginExecuteReader to add a WaitHandle for the process
+ ' to the array.
+ connection1.Open()
+ Dim command1 As New SqlCommand(commandText1, connection1)
+ Dim result1 As IAsyncResult = _
+ command1.BeginExecuteNonQuery()
+ waitHandles(0) = result1.AsyncWaitHandle
+
+ connection2.Open()
+ Dim command2 As New SqlCommand(commandText2, connection2)
+ Dim result2 As IAsyncResult = _
+ command2.BeginExecuteNonQuery()
+ waitHandles(1) = result2.AsyncWaitHandle
+
+ connection3.Open()
+ Dim command3 As New SqlCommand(commandText3, connection3)
+ Dim result3 As IAsyncResult = _
+ command3.BeginExecuteNonQuery()
+ waitHandles(2) = result3.AsyncWaitHandle
+
+ ' WaitAll waits for all of the processes to complete.
' The return value is True if all processes completed,
- ' False if any process timed out.
- Dim result As Boolean = _
- WaitHandle.WaitAll(waitHandles, 60000, False)
- If result Then
- Dim rowCount1 As Long = _
- command1.EndExecuteNonQuery(result1)
- TextBox1.Text = _
- "Completed " & _
- System.DateTime.Now.ToLongTimeString()
-
- Dim rowCount2 As Long = _
- command2.EndExecuteNonQuery(result2)
- TextBox2.Text = _
- "Completed " & _
- System.DateTime.Now.ToLongTimeString()
-
- Dim rowCount3 As Long = _
- command3.EndExecuteNonQuery(result3)
- TextBox3.Text = _
- "Completed " & _
- System.DateTime.Now.ToLongTimeString()
- Else
- Throw New Exception("Timeout")
- End If
- Catch ex As Exception
- TextBox4.Text = ex.ToString
- End Try
- connection1.Close()
- connection2.Close()
- connection3.Close()
-
- End Sub
-```
-
-```csharp
-// Add the following using statements, if they are not already there.
-using System;
-using System.Data;
-using System.Configuration;
-using System.Web;
-using System.Web.Security;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using System.Web.UI.WebControls.WebParts;
-using System.Web.UI.HtmlControls;
-using System.Threading;
-using System.Data.SqlClient;
-
-// Add this code to the page's class
-string GetConnectionString()
+ ' False if any process timed out.
+ Dim result As Boolean = _
+ WaitHandle.WaitAll(waitHandles, 60000, False)
+ If result Then
+ Dim rowCount1 As Long = _
+ command1.EndExecuteNonQuery(result1)
+ TextBox1.Text = _
+ "Completed " & _
+ System.DateTime.Now.ToLongTimeString()
+
+ Dim rowCount2 As Long = _
+ command2.EndExecuteNonQuery(result2)
+ TextBox2.Text = _
+ "Completed " & _
+ System.DateTime.Now.ToLongTimeString()
+
+ Dim rowCount3 As Long = _
+ command3.EndExecuteNonQuery(result3)
+ TextBox3.Text = _
+ "Completed " & _
+ System.DateTime.Now.ToLongTimeString()
+ Else
+ Throw New Exception("Timeout")
+ End If
+ Catch ex As Exception
+ TextBox4.Text = ex.ToString
+ End Try
+ connection1.Close()
+ connection2.Close()
+ connection3.Close()
+
+ End Sub
+```
+
+```csharp
+// Add the following using directives, if they aren't already there.
+using System;
+using System.Data;
+using System.Configuration;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+using System.Threading;
+using System.Data.SqlClient;
+
+// Add this code to the page's class
+string GetConnectionString()
// To avoid storing the connection string in your code,
// you can retrieve it from a configuration file.
// If you have not included "Asynchronous Processing=true"
- // in the connection string, the command will not be able
- // to execute asynchronously.
-{
- return "Data Source=(local);Integrated Security=SSPI;" +
- "Initial Catalog=AdventureWorks;" +
- "Asynchronous Processing=true";
-}
-void Button1_Click(object sender, System.EventArgs e)
-{
+ // in the connection string, the command will not be able
+ // to execute asynchronously.
+{
+ return "Data Source=(local);Integrated Security=SSPI;" +
+ "Initial Catalog=AdventureWorks;" +
+ "Asynchronous Processing=true";
+}
+void Button1_Click(object sender, System.EventArgs e)
+{
// In a real-world application, you might be connecting to
- // three different servers or databases. For the example,
- // we connect to only one.
-
+ // three different servers or databases. For the example,
+ // we connect to only one.
+
SqlConnection connection1 =
- new SqlConnection(GetConnectionString());
+ new SqlConnection(GetConnectionString());
SqlConnection connection2 =
- new SqlConnection(GetConnectionString());
+ new SqlConnection(GetConnectionString());
SqlConnection connection3 =
- new SqlConnection(GetConnectionString());
+ new SqlConnection(GetConnectionString());
// To keep the example simple, all three asynchronous
- // processes execute UPDATE queries that result in
- // no change to the data. WAITFOR
- // commands are used to emulate long-running processes
- // that complete after different periods of time.
-
+ // processes execute UPDATE queries that result in
+ // no change to the data. WAITFOR
+ // commands are used to emulate long-running processes
+ // that complete after different periods of time.
+
string commandText1 =
- "UPDATE Production.Product " +
- "SET ReorderPoint = ReorderPoint + 1 " +
- "WHERE ReorderPoint Is Not Null;" +
- "WAITFOR DELAY '0:0:01';" +
- "UPDATE Production.Product " +
- "SET ReorderPoint = ReorderPoint - 1 " +
- "WHERE ReorderPoint Is Not Null";
-
+ "UPDATE Production.Product " +
+ "SET ReorderPoint = ReorderPoint + 1 " +
+ "WHERE ReorderPoint Is Not Null;" +
+ "WAITFOR DELAY '0:0:01';" +
+ "UPDATE Production.Product " +
+ "SET ReorderPoint = ReorderPoint - 1 " +
+ "WHERE ReorderPoint Is Not Null";
+
string commandText2 =
- "UPDATE Production.Product " +
- "SET ReorderPoint = ReorderPoint + 1 " +
- "WHERE ReorderPoint Is Not Null;" +
- "WAITFOR DELAY '0:0:05';" +
- "UPDATE Production.Product " +
- "SET ReorderPoint = ReorderPoint - 1 " +
- "WHERE ReorderPoint Is Not Null";
-
- string commandText3 =
- "UPDATE Production.Product " +
- "SET ReorderPoint = ReorderPoint + 1 " +
- "WHERE ReorderPoint Is Not Null;" +
- "WAITFOR DELAY '0:0:10';" +
- "UPDATE Production.Product " +
- "SET ReorderPoint = ReorderPoint - 1 " +
- "WHERE ReorderPoint Is Not Null";
- try
+ "UPDATE Production.Product " +
+ "SET ReorderPoint = ReorderPoint + 1 " +
+ "WHERE ReorderPoint Is Not Null;" +
+ "WAITFOR DELAY '0:0:05';" +
+ "UPDATE Production.Product " +
+ "SET ReorderPoint = ReorderPoint - 1 " +
+ "WHERE ReorderPoint Is Not Null";
+
+ string commandText3 =
+ "UPDATE Production.Product " +
+ "SET ReorderPoint = ReorderPoint + 1 " +
+ "WHERE ReorderPoint Is Not Null;" +
+ "WAITFOR DELAY '0:0:10';" +
+ "UPDATE Production.Product " +
+ "SET ReorderPoint = ReorderPoint - 1 " +
+ "WHERE ReorderPoint Is Not Null";
+ try
// For each process, open a connection and begin
// execution. Use the IAsyncResult object returned by
// BeginExecuteReader to add a WaitHandle for the
- // process to the array.
- {
- connection1.Open();
- SqlCommand command1 =
- new SqlCommand(commandText1, connection1);
- IAsyncResult result1 = command1.BeginExecuteNonQuery();
- WaitHandle waitHandle1 = result1.AsyncWaitHandle;
- connection2.Open();
-
- SqlCommand command2 =
- new SqlCommand(commandText2, connection2);
- IAsyncResult result2 = command2.BeginExecuteNonQuery();
- WaitHandle waitHandle2 = result2.AsyncWaitHandle;
- connection3.Open();
-
- SqlCommand command3 =
- new SqlCommand(commandText3, connection3);
- IAsyncResult result3 = command3.BeginExecuteNonQuery();
- WaitHandle waitHandle3 = result3.AsyncWaitHandle;
-
- WaitHandle[] waitHandles = {
- waitHandle1, waitHandle2, waitHandle3
- };
-
- bool result;
+ // process to the array.
+ {
+ connection1.Open();
+ SqlCommand command1 =
+ new SqlCommand(commandText1, connection1);
+ IAsyncResult result1 = command1.BeginExecuteNonQuery();
+ WaitHandle waitHandle1 = result1.AsyncWaitHandle;
+ connection2.Open();
+
+ SqlCommand command2 =
+ new SqlCommand(commandText2, connection2);
+ IAsyncResult result2 = command2.BeginExecuteNonQuery();
+ WaitHandle waitHandle2 = result2.AsyncWaitHandle;
+ connection3.Open();
+
+ SqlCommand command3 =
+ new SqlCommand(commandText3, connection3);
+ IAsyncResult result3 = command3.BeginExecuteNonQuery();
+ WaitHandle waitHandle3 = result3.AsyncWaitHandle;
+
+ WaitHandle[] waitHandles = {
+ waitHandle1, waitHandle2, waitHandle3
+ };
+
+ bool result;
// WaitAll waits for all of the processes to
- // complete. The return value is True if the processes
- // all completed successfully, False if any process
- // timed out.
-
- result = WaitHandle.WaitAll(waitHandles, 60000, false);
- if(result)
- {
+ // complete. The return value is True if the processes
+ // all completed successfully, False if any process
+ // timed out.
+
+ result = WaitHandle.WaitAll(waitHandles, 60000, false);
+ if(result)
+ {
long rowCount1 =
- command1.EndExecuteNonQuery(result1);
- TextBox1.Text = "Completed " +
- System.DateTime.Now.ToLongTimeString();
+ command1.EndExecuteNonQuery(result1);
+ TextBox1.Text = "Completed " +
+ System.DateTime.Now.ToLongTimeString();
long rowCount2 =
- command2.EndExecuteNonQuery(result2);
- TextBox2.Text = "Completed " +
- System.DateTime.Now.ToLongTimeString();
-
+ command2.EndExecuteNonQuery(result2);
+ TextBox2.Text = "Completed " +
+ System.DateTime.Now.ToLongTimeString();
+
long rowCount3 =
- command3.EndExecuteNonQuery(result3);
- TextBox3.Text = "Completed " +
- System.DateTime.Now.ToLongTimeString();
- }
- else
- {
- throw new Exception("Timeout");
- }
- }
-
- catch (Exception ex)
- {
- TextBox4.Text = ex.ToString();
- }
- connection1.Close();
- connection2.Close();
- connection3.Close();
-}
-```
-
+ command3.EndExecuteNonQuery(result3);
+ TextBox3.Text = "Completed " +
+ System.DateTime.Now.ToLongTimeString();
+ }
+ else
+ {
+ throw new Exception("Timeout");
+ }
+ }
+
+ catch (Exception ex)
+ {
+ TextBox4.Text = ex.ToString();
+ }
+ connection1.Close();
+ connection2.Close();
+ connection3.Close();
+}
+```
+
## See also
- [Asynchronous Operations](asynchronous-operations.md)
diff --git a/docs/framework/interop/how-to-create-com-wrappers.md b/docs/framework/interop/how-to-create-com-wrappers.md
index 08f1292593003..38c0266547dd2 100644
--- a/docs/framework/interop/how-to-create-com-wrappers.md
+++ b/docs/framework/interop/how-to-create-com-wrappers.md
@@ -31,41 +31,41 @@ In Visual Studio, you can add the COM wrapper as a reference to your project.
In **Solution Explorer**, note that the COM component is added to the References folder in your project.
-You can now write code to access the COM object. You can begin by declaring the object, such as with an `Imports` statement for Visual Basic or a `Using` statement for C#.
+You can now write code to access the COM object. You can begin by declaring the object, such as with an `Imports` statement for Visual Basic or a `Using` directive for C#.
> [!NOTE]
> If you want to program Microsoft Office components, first install the [Microsoft Office Primary Interop Assemblies Redistributable](https://www.microsoft.com/Download/details.aspx?id=3508).
-
-### To create a runtime callable wrapper using .NET Framework tools
-
-- Run the [Tlbimp.exe (Type Library Importer)](../tools/tlbimp-exe-type-library-importer.md) tool.
-
- This tool creates an assembly that contains run-time metadata for the types defined in the original type library.
-
-## Wrap Managed Objects in a Native Application
-
-### To create a COM callable wrapper using Visual Studio
-
-1. Create a Class Library project for the managed class that you want to run in native code. The class must have a parameterless constructor.
-
- Verify that you have a complete four-part version number for your assembly in the AssemblyInfo file. This number is required for maintaining versioning in the Windows registry. For more information about version numbers, see [Assembly Versioning](../../standard/assembly/versioning.md).
-
-2. On the **Project** menu, click **Properties**.
-
-3. Click the **Compile** tab.
-
-4. Select the **Register for COM interop** check box.
-
- When you build the project, the assembly is automatically registered for COM interop. If you are building a native application in Visual Studio, you can use the assembly by clicking **Add Reference** on the **Project** menu.
-
-### To create a COM callable wrapper using .NET Framework tools
-
-Run the [Regasm.exe (Assembly Registration Tool)](../tools/regasm-exe-assembly-registration-tool.md) tool.
-
-This tool reads the assembly metadata and adds the necessary entries to the registry. As a result, COM clients can create .NET Framework classes transparently. You can use the assembly as if it were a native COM class.
-
-You can run Regasm.exe on an assembly located in any directory, and then run the [Gacutil.exe (Global Assembly Cache Tool)](../tools/gacutil-exe-gac-tool.md) to move it to the global assembly cache. Moving the assembly does not invalidate location registry entries, because the global assembly cache is always examined if the assembly is not found elsewhere.
-
+
+### To create a runtime callable wrapper using .NET Framework tools
+
+- Run the [Tlbimp.exe (Type Library Importer)](../tools/tlbimp-exe-type-library-importer.md) tool.
+
+ This tool creates an assembly that contains run-time metadata for the types defined in the original type library.
+
+## Wrap Managed Objects in a Native Application
+
+### To create a COM callable wrapper using Visual Studio
+
+1. Create a Class Library project for the managed class that you want to run in native code. The class must have a parameterless constructor.
+
+ Verify that you have a complete four-part version number for your assembly in the AssemblyInfo file. This number is required for maintaining versioning in the Windows registry. For more information about version numbers, see [Assembly Versioning](../../standard/assembly/versioning.md).
+
+2. On the **Project** menu, click **Properties**.
+
+3. Click the **Compile** tab.
+
+4. Select the **Register for COM interop** check box.
+
+ When you build the project, the assembly is automatically registered for COM interop. If you are building a native application in Visual Studio, you can use the assembly by clicking **Add Reference** on the **Project** menu.
+
+### To create a COM callable wrapper using .NET Framework tools
+
+Run the [Regasm.exe (Assembly Registration Tool)](../tools/regasm-exe-assembly-registration-tool.md) tool.
+
+This tool reads the assembly metadata and adds the necessary entries to the registry. As a result, COM clients can create .NET Framework classes transparently. You can use the assembly as if it were a native COM class.
+
+You can run Regasm.exe on an assembly located in any directory, and then run the [Gacutil.exe (Global Assembly Cache Tool)](../tools/gacutil-exe-gac-tool.md) to move it to the global assembly cache. Moving the assembly does not invalidate location registry entries, because the global assembly cache is always examined if the assembly is not found elsewhere.
+
## See also
- [Runtime Callable Wrapper](../../standard/native-interop/runtime-callable-wrapper.md)
diff --git a/docs/framework/mef/index.md b/docs/framework/mef/index.md
index 2bc438605f946..81e3dbe6d4016 100644
--- a/docs/framework/mef/index.md
+++ b/docs/framework/mef/index.md
@@ -66,7 +66,7 @@ To download the complete code for this example, see the [SimpleCalculator sample
- Add a reference to the `System.ComponentModel.Composition` assembly, where MEF resides.
-- Open *Module1.vb* or *Program.cs* and add `Imports` or `using` statements for `System.ComponentModel.Composition` and `System.ComponentModel.Composition.Hosting`. These two namespaces contain MEF types you will need to develop an extensible application.
+- Open *Module1.vb* or *Program.cs* and add `Imports` or `using` directives for `System.ComponentModel.Composition` and `System.ComponentModel.Composition.Hosting`. These two namespaces contain MEF types you will need to develop an extensible application.
- If you're using Visual Basic, add the `Public` keyword to the line that declares the `Module1` module.
@@ -439,7 +439,7 @@ catalog.Catalogs.Add(
Replace the example path with the path to your Extensions directory. (This absolute path is for debugging purposes only. In a production application, you would use a relative path.) The will now add any parts found in any assemblies in the Extensions directory to the composition container.
-In the ExtendedOperations project, add references to SimpleCalculator and System.ComponentModel.Composition. In the ExtendedOperations class file, add an `Imports` or a `using` statement for System.ComponentModel.Composition. In Visual Basic, also add an `Imports` statement for SimpleCalculator. Then add the following class to the ExtendedOperations class file:
+In the `ExtendedOperations` project, add references to `SimpleCalculator` and `System.ComponentModel.Composition`. In the `ExtendedOperations` class file, add an `Imports` or a `using` directive for `System.ComponentModel.Composition`. In Visual Basic, also add an `Imports` statement for `SimpleCalculator`. Then add the following class to the `ExtendedOperations` class file:
```vb
diff --git a/docs/framework/wcf/diagnostics/message-flow-overview.md b/docs/framework/wcf/diagnostics/message-flow-overview.md
index 00c7a00e32920..95c2f0b14dc1c 100644
--- a/docs/framework/wcf/diagnostics/message-flow-overview.md
+++ b/docs/framework/wcf/diagnostics/message-flow-overview.md
@@ -46,13 +46,13 @@ In a distributed system containing interconnected services, it is necessary to d
```
-8. In Program.cs in the client, add the following Using statement.
+8. In Program.cs in the client, add the following `using` directive.
```csharp
using System.Diagnostics;
```
-9. In the Main method in the program.cs file in the client project, set the Trace GUID to be propagated in the event log.
+9. In the `Main` method in the program.cs file in the client project, set the Trace GUID to be propagated in the event log.
```csharp
Guid guid = Guid.NewGuid();
diff --git a/docs/framework/wcf/feature-details/discoverable-service-that-registers-with-the-discovery-proxy.md b/docs/framework/wcf/feature-details/discoverable-service-that-registers-with-the-discovery-proxy.md
index 5d6ee0197eec5..8379fb5fe6941 100644
--- a/docs/framework/wcf/feature-details/discoverable-service-that-registers-with-the-discovery-proxy.md
+++ b/docs/framework/wcf/feature-details/discoverable-service-that-registers-with-the-discovery-proxy.md
@@ -21,7 +21,7 @@ This topic is the second of four topics that discusses how to implement a discov
3. Add a new class to the project called `CalculatorService`.
-4. Add the following using statements.
+4. Add the following `using` directives.
```csharp
using System;
@@ -90,7 +90,7 @@ This topic is the second of four topics that discusses how to implement a discov
1. Open the Program.cs file that was generated when you created the project.
-2. Add the following using statements.
+2. Add the following `using` directives.
```csharp
using System;
@@ -194,7 +194,7 @@ namespace Microsoft.Samples.Discovery
Console.WriteLine("Return: {0}", result);
return result;
}
-
+
public double Subtract(double n1, double n2)
{
double result = n1 - n2;
diff --git a/docs/framework/wcf/feature-details/how-to-dynamic-update.md b/docs/framework/wcf/feature-details/how-to-dynamic-update.md
index ae6551bb85a26..05dfc6fc038e6 100644
--- a/docs/framework/wcf/feature-details/how-to-dynamic-update.md
+++ b/docs/framework/wcf/feature-details/how-to-dynamic-update.md
@@ -77,7 +77,7 @@ This topic outlines the basic steps required to create and dynamically update th
Dynamic configuration of the Routing Service can only be performed in code by creating a new and using to replace the current configuration. For this example, the Routing Service is self-hosted within a console application. After the application has started, you can modify the routing configuration by entering ‘regular’ or ‘rounding’ at the console window to configure the destination endpoint that messages are routed to; regularCalc when ‘regular’ is entered, otherwise roundingCalc when ‘rounding’ is entered.
-1. The following using statements must be added in order to support the Routing Service.
+1. The following `using` directives must be added in order to support the Routing Service.
```csharp
using System;
diff --git a/docs/framework/wcf/feature-details/how-to-host-a-wcf-service-in-a-managed-windows-service.md b/docs/framework/wcf/feature-details/how-to-host-a-wcf-service-in-a-managed-windows-service.md
index be47bc31da258..7b4c6f59c49c4 100644
--- a/docs/framework/wcf/feature-details/how-to-host-a-wcf-service-in-a-managed-windows-service.md
+++ b/docs/framework/wcf/feature-details/how-to-host-a-wcf-service-in-a-managed-windows-service.md
@@ -26,12 +26,10 @@ The service code includes a service implementation of the service contract, a Wi
4. Add references to the following assemblies:
- System.ServiceModel.dll
-
- System.ServiceProcess.dll
-
- System.Configuration.Install.dll
-5. Add the following using statements to Service.cs.
+5. Add the following `using` directives to Service.cs.
[!code-csharp[c_HowTo_HostInNTService#0](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto_hostinntservice/cs/service.cs#0)]
[!code-vb[c_HowTo_HostInNTService#0](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_howto_hostinntservice/vb/service.vb#0)]
diff --git a/docs/framework/wcf/feature-details/how-to-host-a-wcf-service-in-iis.md b/docs/framework/wcf/feature-details/how-to-host-a-wcf-service-in-iis.md
index ab8c43654f37b..157d62c036e2c 100644
--- a/docs/framework/wcf/feature-details/how-to-host-a-wcf-service-in-iis.md
+++ b/docs/framework/wcf/feature-details/how-to-host-a-wcf-service-in-iis.md
@@ -2,76 +2,76 @@
title: "How to: Host a WCF Service in IIS"
description: Learn how to create a WCF service that is hosted in Internet Information Services (IIS). You can use IIS hosting only with an HTTP transport.
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
ms.assetid: b044b1c9-c1e5-4c9f-84d8-0f02f4537f8b
---
# How to: Host a WCF Service in IIS
-This topic outlines the basic steps required to create a Windows Communication Foundation (WCF) service that is hosted in Internet Information Services (IIS). This topic assumes you are familiar with IIS and understand how to use the IIS management tool to create and manage IIS applications. For more information about IIS see [Internet Information Services](https://www.iis.net/). A WCF service that runs in the IIS environment takes full advantage of IIS features, such as process recycling, idle shutdown, process health monitoring, and message-based activation. This hosting option requires that IIS be properly configured, but it does not require that any hosting code be written as part of the application. You can use IIS hosting only with an HTTP transport.
-
- For more information about how WCF and ASP.NET interact, see [WCF Services and ASP.NET](wcf-services-and-aspnet.md). For more information about configuring security, see [Security](security.md).
-
- For the source copy of this example, see [IIS Hosting Using Inline Code](../samples/iis-hosting-using-inline-code.md).
-
-### To create a service hosted by IIS
-
-1. Confirm that IIS is installed and running on your computer. For more information about installing and configuring IIS see [Installing and Configuring IIS 7.0](/iis/install/installing-iis-7/installing-necessary-iis-components-on-windows-vista)
-
-2. Create a new folder for your application files called "IISHostedCalcService", ensure that ASP.NET has access to the contents of the folder, and use the IIS management tool to create a new IIS application that is physically located in this application directory. When creating an alias for the application directory use "IISHostedCalc".
-
-3. Create a new file named "service.svc" in the application directory. Edit this file by adding the following @ServiceHost element.
-
+This topic outlines the basic steps required to create a Windows Communication Foundation (WCF) service that is hosted in Internet Information Services (IIS). This topic assumes you are familiar with IIS and understand how to use the IIS management tool to create and manage IIS applications. For more information about IIS see [Internet Information Services](https://www.iis.net/). A WCF service that runs in the IIS environment takes full advantage of IIS features, such as process recycling, idle shutdown, process health monitoring, and message-based activation. This hosting option requires that IIS be properly configured, but it does not require that any hosting code be written as part of the application. You can use IIS hosting only with an HTTP transport.
+
+ For more information about how WCF and ASP.NET interact, see [WCF Services and ASP.NET](wcf-services-and-aspnet.md). For more information about configuring security, see [Security](security.md).
+
+ For the source copy of this example, see [IIS Hosting Using Inline Code](../samples/iis-hosting-using-inline-code.md).
+
+### To create a service hosted by IIS
+
+1. Confirm that IIS is installed and running on your computer. For more information about installing and configuring IIS see [Installing and Configuring IIS 7.0](/iis/install/installing-iis-7/installing-necessary-iis-components-on-windows-vista)
+
+2. Create a new folder for your application files called "IISHostedCalcService", ensure that ASP.NET has access to the contents of the folder, and use the IIS management tool to create a new IIS application that is physically located in this application directory. When creating an alias for the application directory use "IISHostedCalc".
+
+3. Create a new file named "service.svc" in the application directory. Edit this file by adding the following @ServiceHost element.
+
```aspx-csharp
<%@ServiceHost language=c# Debug="true" Service="Microsoft.ServiceModel.Samples.CalculatorService"%>
- ```
-
-4. Create an App_Code subdirectory within the application directory.
-
-5. Create a code file named Service.cs in the App_Code subdirectory.
-
-6. Add the following using statements to the top of the Service.cs file.
-
- ```csharp
- using System;
- using System.ServiceModel;
- ```
-
-7. Add the following namespace declaration after the using statements.
-
- ```csharp
- namespace Microsoft.ServiceModel.Samples
- {
- }
- ```
-
-8. Define the service contract inside the namespace declaration as shown in the following code.
-
+ ```
+
+4. Create an App_Code subdirectory within the application directory.
+
+5. Create a code file named Service.cs in the App_Code subdirectory.
+
+6. Add the following `using` directives to the top of the Service.cs file.
+
+ ```csharp
+ using System;
+ using System.ServiceModel;
+ ```
+
+7. Add the following namespace declaration after the `using` directives.
+
+ ```csharp
+ namespace Microsoft.ServiceModel.Samples
+ {
+ }
+ ```
+
+8. Define the service contract inside the namespace declaration as shown in the following code.
+
[!code-csharp[c_HowTo_HostInIIS#11](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto_hostiniis/cs/source.cs#11)]
- [!code-vb[c_HowTo_HostInIIS#11](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_howto_hostiniis/vb/source.vb#11)]
-
-9. Implement the service contract after the service contract definition as shown in the following code.
-
+ [!code-vb[c_HowTo_HostInIIS#11](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_howto_hostiniis/vb/source.vb#11)]
+
+9. Implement the service contract after the service contract definition as shown in the following code.
+
[!code-csharp[c_HowTo_HostInIIS#12](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto_hostiniis/cs/source.cs#12)]
- [!code-vb[c_HowTo_HostInIIS#12](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_howto_hostiniis/vb/source.vb#12)]
-
-10. Create a file named "Web.config" in the application directory and add the following configuration code into the file. At run time, the WCF infrastructure uses the information to construct an endpoint that client applications can communicate with.
-
+ [!code-vb[c_HowTo_HostInIIS#12](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_howto_hostiniis/vb/source.vb#12)]
+
+10. Create a file named "Web.config" in the application directory and add the following configuration code into the file. At run time, the WCF infrastructure uses the information to construct an endpoint that client applications can communicate with.
+
[!code-xml[c_HowTo_HostInIIS#100](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto_hostiniis/common/web.config#100)]
-
- This example explicitly specifies endpoints in the configuration file. If you do not add any endpoints to the service, the runtime adds default endpoints for you. For more information about default endpoints, bindings, and behaviors see [Simplified Configuration](../simplified-configuration.md) and [Simplified Configuration for WCF Services](../samples/simplified-configuration-for-wcf-services.md).
-
-11. To make sure the service is hosted correctly, open a browser and browse to the service's URL: `http://localhost/IISHostedCalc/Service.svc`
-
-## Example
-
- The following is a complete listing of the code for the IIS hosted calculator service.
-
+
+ This example explicitly specifies endpoints in the configuration file. If you do not add any endpoints to the service, the runtime adds default endpoints for you. For more information about default endpoints, bindings, and behaviors see [Simplified Configuration](../simplified-configuration.md) and [Simplified Configuration for WCF Services](../samples/simplified-configuration-for-wcf-services.md).
+
+11. To make sure the service is hosted correctly, open a browser and browse to the service's URL: `http://localhost/IISHostedCalc/Service.svc`
+
+## Example
+
+ The following is a complete listing of the code for the IIS hosted calculator service.
+
[!code-csharp[C_HowTo_HostInIIS#1](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto_hostiniis/cs/source.cs#1)]
[!code-vb[C_HowTo_HostInIIS#1](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_howto_hostiniis/vb/source.vb#1)]
- [!code-xml[c_HowTo_HostInIIS#100](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto_hostiniis/common/web.config#100)]
-
+ [!code-xml[c_HowTo_HostInIIS#100](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_howto_hostiniis/common/web.config#100)]
+
## See also
- [Hosting in Internet Information Services](hosting-in-internet-information-services.md)
diff --git a/docs/framework/wcf/feature-details/how-to-implement-a-discovery-proxy.md b/docs/framework/wcf/feature-details/how-to-implement-a-discovery-proxy.md
index 3846c473169d3..18c60f43abbdd 100644
--- a/docs/framework/wcf/feature-details/how-to-implement-a-discovery-proxy.md
+++ b/docs/framework/wcf/feature-details/how-to-implement-a-discovery-proxy.md
@@ -35,7 +35,7 @@ This topic explains how to implement a discovery proxy. For more information abo
1. Add a new code file to your project and name it DiscoveryProxy.cs.
-2. Add the following `using` statements to DiscoveryProxy.cs.
+2. Add the following `using` directives to DiscoveryProxy.cs.
```csharp
using System;
@@ -323,7 +323,7 @@ The OnBegin.. / OnEnd.. methods provide the logic for the subsequent discovery o
2. Create a new code file called AsyncResult.cs.
-3. Add the following `using` statements to AsyncResult.cs.
+3. Add the following `using` directives to AsyncResult.cs.
```csharp
using System;
@@ -482,7 +482,7 @@ The OnBegin.. / OnEnd.. methods provide the logic for the subsequent discovery o
1. Open the Program.cs file in the DiscoveryProxyExample project.
-2. Add the following `using` statements.
+2. Add the following `using` directives.
```csharp
using System;
diff --git a/docs/framework/wcf/feature-details/how-to-programmatically-add-discoverability-to-a-wcf-service-and-client.md b/docs/framework/wcf/feature-details/how-to-programmatically-add-discoverability-to-a-wcf-service-and-client.md
index e15fcc5a242ee..4d9c57ab805f0 100644
--- a/docs/framework/wcf/feature-details/how-to-programmatically-add-discoverability-to-a-wcf-service-and-client.md
+++ b/docs/framework/wcf/feature-details/how-to-programmatically-add-discoverability-to-a-wcf-service-and-client.md
@@ -14,7 +14,7 @@ This topic explains how to make a Windows Communication Foundation (WCF) service
2. Add a reference to `System.ServiceModel.Discovery.dll` to the service project. You may see an error message saying "System. ServiceModel.Discovery.dll or one of its dependencies requires a later version of the .NET Framework than the one specified in the project …" If you see this message, right-click the project in the Solution Explorer and choose **Properties**. In the **Project Properties** window, make sure that the **Target Framework** is [!INCLUDE[netfx_current_long](../../../../includes/netfx-current-long-md.md)].
-3. Open the Service.cs file and add the following `using` statement.
+3. Open the Service.cs file and add the following `using` directive.
```csharp
using System.ServiceModel.Discovery;
@@ -60,7 +60,7 @@ This topic explains how to make a Windows Communication Foundation (WCF) service
4. Open Program.cs.
-5. Add the following `using` statements.
+5. Add the following `using` directives.
```csharp
using System.ServiceModel;
diff --git a/docs/framework/wcf/samples/use-close-abort-release-wcf-client-resources.md b/docs/framework/wcf/samples/use-close-abort-release-wcf-client-resources.md
index 90fb61f4e4ea0..674552706dbc3 100644
--- a/docs/framework/wcf/samples/use-close-abort-release-wcf-client-resources.md
+++ b/docs/framework/wcf/samples/use-close-abort-release-wcf-client-resources.md
@@ -68,7 +68,7 @@ catch (Exception e)
```
> [!NOTE]
-> The using statement and ServiceHost: Many self-hosting applications do little more than host a service, and ServiceHost.Close rarely throws an exception, so such applications can safely use the using statement with ServiceHost. However, be aware that ServiceHost.Close can throw a `CommunicationException`, so if your application continues after closing the ServiceHost, you should avoid the using statement and follow the pattern previously given.
+> The `using` statement and `ServiceHost`: Many self-hosting applications do little more than host a service, and `ServiceHost.Close` rarely throws an exception, so such applications can safely use the `using` statement with `ServiceHost`. However, be aware that `ServiceHost.Close` can throw a `CommunicationException`, so if your application continues after closing the `ServiceHost`, you should avoid the `using` statement and follow the pattern previously given.
When you run the sample, the operation responses and exceptions are displayed in the client console window.
diff --git a/docs/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer.md b/docs/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer.md
index f5a7f9ec1b222..4a1ef08708443 100644
--- a/docs/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer.md
+++ b/docs/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer.md
@@ -64,7 +64,7 @@ In this section, you add a custom event log to the Windows service. The namespace:
+1. Add a `using` directive to **MyNewService.cs** (if it doesn't already exist), or an `Imports` statement to **MyNewService.vb**, for the namespace:
```csharp
using System.Diagnostics;
@@ -94,7 +94,7 @@ To set up a simple polling mechanism, use the namespace:
+1. Add a `using` directive to **MyNewService.cs**, or an `Imports` statement to **MyNewService.vb**, for the namespace:
```csharp
using System.Timers;
@@ -176,7 +176,7 @@ Services report their status to the [Service Control Manager](/windows/desktop/S
You can implement the `SERVICE_START_PENDING` and `SERVICE_STOP_PENDING` status settings by adding code that calls the Windows [SetServiceStatus](/windows/desktop/api/winsvc/nf-winsvc-setservicestatus) function.
-1. Add a `using` statement to **MyNewService.cs**, or an `Imports` statement to **MyNewService.vb**, for the namespace:
+1. Add a `using` directive to **MyNewService.cs**, or an `Imports` statement to **MyNewService.vb**, for the namespace:
```csharp
using System.Runtime.InteropServices;
diff --git a/docs/framework/windows-workflow-foundation/how-to-create-a-workflow-service-that-consumes-an-existing-service-contract.md b/docs/framework/windows-workflow-foundation/how-to-create-a-workflow-service-that-consumes-an-existing-service-contract.md
index 877ab2f8f08d3..14d07dfb11da8 100644
--- a/docs/framework/windows-workflow-foundation/how-to-create-a-workflow-service-that-consumes-an-existing-service-contract.md
+++ b/docs/framework/windows-workflow-foundation/how-to-create-a-workflow-service-that-consumes-an-existing-service-contract.md
@@ -6,55 +6,55 @@ ms.assetid: 11d11b59-acc4-48bf-8e4b-e97b516aa0a9
---
# How to: Create a workflow service that consumes an existing service contract
-.NET Framework 4.5 features better integration between web services and workflows in the form of contract-first workflow development. The contract-first workflow development tool allows you to design the contract in code first. The tool then automatically generates an activity template in the toolbox for the operations in the contract.
-
+.NET Framework 4.5 features better integration between web services and workflows in the form of contract-first workflow development. The contract-first workflow development tool allows you to design the contract in code first. The tool then automatically generates an activity template in the toolbox for the operations in the contract.
+
> [!NOTE]
-> This topic provides step-by-step guidance on creating a contract-first workflow service. For more information about contract-first workflow service development, see [Contract First Workflow Service Development](contract-first-workflow-service-development.md).
-
-### Creating the workflow project
-
-1. In Visual Studio, select **File**, **New Project**. Select the **WCF** node under the **C#** node in the **Templates** tree, and select the **WCF Workflow Service Application** template.
-
-2. Name the new project `ContractFirst` and click **Ok**.
-
-### Creating the service contract
-
-1. Right-click the project in **Solution Explorer** and select **Add**, **New Item…**. Select the **Code** node on the left, and the **Class** template on the right. Name the new class `IBookService` and click **Ok**.
-
-2. In the top of the code window that appears, add a Using statement to `System.ServiceModel`.
-
- ```csharp
- using System.ServiceModel;
- ```
-
-3. Change the sample class definition to the following interface definition.
-
- ```csharp
- [ServiceContract]
- public interface IBookService
- {
- [OperationContract]
- void Buy(string bookName);
-
- [OperationContract(IsOneWay=true)]
- void Checkout();
- }
- ```
-
-4. Build the project by pressing **Ctrl+Shift+B**.
-
-### Importing the service contract
-
-1. Right-click the project in **Solution Explorer** and select **Import Service Contract**. Under **\**, open all sub-nodes and select **IBookService**. Click **OK**.
-
-2. A dialog will open, alerting you that the operation completed successfully, and that the generated activities will appear in the toolbox after you build the project. Click **OK**.
-
-3. Build the project by pressing **Ctrl+Shift+B**, so that the imported activities will appear in the toolbox.
-
-4. In **Solution Explorer**, open Service1.xamlx. The workflow service will appear in the designer.
-
-5. Select the **Sequence** activity. In the Properties window, click the **…** button in the **ImplementedContract** property. In the **Type Collection Editor** window that appears, click the **Type** dropdown, and select the **Browse for Types…** entry. In the **Browse and Select a .NET Type** dialog, under **\**, open all sub-nodes and select **IBookService**. Click **OK**. In the **Type Collection Editor** dialog, click **OK**.
-
-6. Select and delete the **ReceiveRequest** and **SendResponse** activities.
-
+> This topic provides step-by-step guidance on creating a contract-first workflow service. For more information about contract-first workflow service development, see [Contract First Workflow Service Development](contract-first-workflow-service-development.md).
+
+### Creating the workflow project
+
+1. In Visual Studio, select **File**, **New Project**. Select the **WCF** node under the **C#** node in the **Templates** tree, and select the **WCF Workflow Service Application** template.
+
+2. Name the new project `ContractFirst` and click **Ok**.
+
+### Creating the service contract
+
+1. Right-click the project in **Solution Explorer** and select **Add**, **New Item…**. Select the **Code** node on the left, and the **Class** template on the right. Name the new class `IBookService` and click **Ok**.
+
+2. In the top of the code window that appears, add a `using` directive to `System.ServiceModel`.
+
+ ```csharp
+ using System.ServiceModel;
+ ```
+
+3. Change the sample class definition to the following interface definition.
+
+ ```csharp
+ [ServiceContract]
+ public interface IBookService
+ {
+ [OperationContract]
+ void Buy(string bookName);
+
+ [OperationContract(IsOneWay=true)]
+ void Checkout();
+ }
+ ```
+
+4. Build the project by pressing **Ctrl+Shift+B**.
+
+### Importing the service contract
+
+1. Right-click the project in **Solution Explorer** and select **Import Service Contract**. Under **\**, open all sub-nodes and select **IBookService**. Click **OK**.
+
+2. A dialog will open, alerting you that the operation completed successfully, and that the generated activities will appear in the toolbox after you build the project. Click **OK**.
+
+3. Build the project by pressing **Ctrl+Shift+B**, so that the imported activities will appear in the toolbox.
+
+4. In **Solution Explorer**, open Service1.xamlx. The workflow service will appear in the designer.
+
+5. Select the **Sequence** activity. In the Properties window, click the **…** button in the **ImplementedContract** property. In the **Type Collection Editor** window that appears, click the **Type** dropdown, and select the **Browse for Types…** entry. In the **Browse and Select a .NET Type** dialog, under **\**, open all sub-nodes and select **IBookService**. Click **OK**. In the **Type Collection Editor** dialog, click **OK**.
+
+6. Select and delete the **ReceiveRequest** and **SendResponse** activities.
+
7. From the toolbox, drag a **Buy_ReceiveAndSendReply** and a **Checkout_Receive** activity onto the **Sequential Service** activity.
diff --git a/docs/framework/windows-workflow-foundation/using-a-custom-activity.md b/docs/framework/windows-workflow-foundation/using-a-custom-activity.md
index 41e6ded2e09e5..d66c44359c7fc 100644
--- a/docs/framework/windows-workflow-foundation/using-a-custom-activity.md
+++ b/docs/framework/windows-workflow-foundation/using-a-custom-activity.md
@@ -6,17 +6,17 @@ ms.topic: "how-to"
---
# Using a custom activity
-Activities that derive from or its subclasses can be composed into larger workflows, or created directly in code. This topic describes how to use custom activities in workflows created either in code or in the designer.
-
+Activities that derive from or its subclasses can be composed into larger workflows, or created directly in code. This article describes how to use custom activities in workflows created either in code or in the designer.
+
> [!NOTE]
-> Custom activities can be used in the same project in which they are defined, as long as both the custom activity and the activity that uses it are compiled (i.e. loaded by an instantiating type generated by the build process) If the referencing activity is loaded dynamically (e.g. using ActivityXAMLServices), then the referenced assembly should be placed in a different project, or the designer-generated XAML needs to be hand-edited to enable this.
-
-#### Using a custom activity to a workflow project
-
-1. Add a reference from the host project to the activity library project containing the custom activity.
-
-2. Build the solution.
-
-3. To use the custom activity in the designer, locate the custom activity in the toolbox, and drag the activity onto the designer surface.
-
-4. To use the custom activity in code, add a Using statement that refers to the custom activity project, and pass a new instance of the activity to .
+> Custom activities can be used in the same project in which they are defined, as long as both the custom activity and the activity that uses it are compiled (that is, loaded by an instantiating type generated by the build process) If the referencing activity is loaded dynamically (for example, using ActivityXAMLServices), then the referenced assembly should be placed in a different project, or the designer-generated XAML needs to be hand-edited to enable this.
+
+## Use a custom activity to a workflow project
+
+1. Add a reference from the host project to the activity library project containing the custom activity.
+
+2. Build the solution.
+
+3. To use the custom activity in the designer, locate the custom activity in the toolbox, and drag the activity onto the designer surface.
+
+4. To use the custom activity in code, add a `using` directive that refers to the custom activity project, and pass a new instance of the activity to .
diff --git a/docs/framework/windows-workflow-foundation/using-activity-extensions.md b/docs/framework/windows-workflow-foundation/using-activity-extensions.md
index 265140bb15076..4454e4a184ef5 100644
--- a/docs/framework/windows-workflow-foundation/using-activity-extensions.md
+++ b/docs/framework/windows-workflow-foundation/using-activity-extensions.md
@@ -8,11 +8,11 @@ ms.topic: "how-to"
Activities can interact with workflow application extensions that allow the host to provide additional functionality that is not explicitly modeled in the workflow. This topic describes how to create and use an extension to count the number of times the activity executes.
-### To use an activity extension to count executions
+## To use an activity extension to count executions
1. Open Visual Studio 2010. Select **New**, **Project**. Under the **Visual C#** node, select **Workflow**. Select **Workflow Console Application** from the list of templates. Name the project `Extensions`. Click **OK** to create the project.
-2. Add a `using` statement in the Program.cs file for the **System.Collections.Generic** namespace.
+2. Add a `using` directive in the Program.cs file for the **System.Collections.Generic** namespace.
```csharp
using System.Collections.Generic;
diff --git a/docs/fundamentals/code-analysis/style-rules/dotnet-formatting-options.md b/docs/fundamentals/code-analysis/style-rules/dotnet-formatting-options.md
index 9c9370d5689d0..224479c515fd1 100644
--- a/docs/fundamentals/code-analysis/style-rules/dotnet-formatting-options.md
+++ b/docs/fundamentals/code-analysis/style-rules/dotnet-formatting-options.md
@@ -12,7 +12,7 @@ The formatting options in this article apply to both C# and Visual Basic. These
## Using directive options
-Use these options to customize how you want using directives to be sorted and grouped:
+Use these options to customize how you want `using` directives to be sorted and grouped:
- [dotnet_sort_system_directives_first](#dotnet_sort_system_directives_first)
- [dotnet_separate_import_directive_groups](#dotnet_separate_import_directive_groups)
@@ -36,7 +36,7 @@ dotnet_separate_import_directive_groups = true
| **Option name** | dotnet_sort_system_directives_first | |
| **Applicable languages** | C# and Visual Basic | |
| **Introduced version** | Visual Studio 2017 | |
-| **Option values** | `true` | Sort `System.*` `using` directives alphabetically, and place them before other using directives. |
+| **Option values** | `true` | Sort `System.*` `using` directives alphabetically, and place them before other `using` directives. |
| | `false` | Do not place `System.*` `using` directives before other `using` directives. |
| **Default option value** | `true` | |
diff --git a/docs/machine-learning/how-to-guides/serve-model-serverless-azure-functions-ml-net.md b/docs/machine-learning/how-to-guides/serve-model-serverless-azure-functions-ml-net.md
index b6147ce8b494e..1b5ab65cf87d2 100644
--- a/docs/machine-learning/how-to-guides/serve-model-serverless-azure-functions-ml-net.md
+++ b/docs/machine-learning/how-to-guides/serve-model-serverless-azure-functions-ml-net.md
@@ -59,7 +59,7 @@ Create a class to predict sentiment. Add a new class to your project:
1. In the **New Azure Function** dialog box, select **Http Trigger** and choose **Anonymous** from the Authorization level dropdown. Then, select the **OK** button.
- The *AnalyzeSentiment.cs* file opens in the code editor. Add the following `using` statement to the top of *AnalyzeSentiment.cs*:
+ The *AnalyzeSentiment.cs* file opens in the code editor. Add the following `using` directive to the top of *AnalyzeSentiment.cs*:
[!code-csharp [AnalyzeUsings](~/machinelearning-samples/samples/csharp/end-to-end-apps/ScalableMLModelOnAzureFunction/SentimentAnalysisFunctionsApp/AnalyzeSentiment.cs#L1-L11)]
@@ -81,7 +81,7 @@ You need to create some classes for your input data and predictions. Add a new c
2. In Solution Explorer, right-click the *DataModels* directory, and then select **Add > Class**.
3. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *SentimentData.cs*. Then, select the **Add** button.
- The *SentimentData.cs* file opens in the code editor. Add the following using statement to the top of *SentimentData.cs*:
+ The *SentimentData.cs* file opens in the code editor. Add the following `using` directive to the top of *SentimentData.cs*:
[!code-csharp [SentimentDataUsings](~/machinelearning-samples/samples/csharp/end-to-end-apps/ScalableMLModelOnAzureFunction/SentimentAnalysisFunctionsApp/DataModels/SentimentData.cs#L1)]
@@ -90,7 +90,7 @@ You need to create some classes for your input data and predictions. Add a new c
[!code-csharp [SentimentData](~/machinelearning-samples/samples/csharp/end-to-end-apps/ScalableMLModelOnAzureFunction/SentimentAnalysisFunctionsApp/DataModels/SentimentData.cs#L5-L13)]
4. In Solution Explorer, right-click the *DataModels* directory, and then select **Add > Class**.
-5. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *SentimentPrediction.cs*. Then, select the **Add** button. The *SentimentPrediction.cs* file opens in the code editor. Add the following using statement to the top of *SentimentPrediction.cs*:
+5. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *SentimentPrediction.cs*. Then, select the **Add** button. The *SentimentPrediction.cs* file opens in the code editor. Add the following `using` directive to the top of *SentimentPrediction.cs*:
[!code-csharp [SentimentPredictionUsings](~/machinelearning-samples/samples/csharp/end-to-end-apps/ScalableMLModelOnAzureFunction/SentimentAnalysisFunctionsApp/DataModels/SentimentPrediction.cs#L1)]
@@ -108,11 +108,11 @@ The following link provides more information if you want to learn more about [de
1. In **Solution Explorer**, right-click the project, and then select **Add** > **Class**.
1. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *Startup.cs*. Then, select the **Add** button.
-1. Add the following using statements to the top of *Startup.cs*:
+1. Add the following `using` directives to the top of *Startup.cs*:
[!code-csharp [StartupUsings](~/machinelearning-samples/samples/csharp/end-to-end-apps/ScalableMLModelOnAzureFunction/SentimentAnalysisFunctionsApp/Startup.cs#L1-L7)]
-1. Remove the existing code below the using statements and add the following code:
+1. Remove the existing code below the `using` directives and add the following code:
```csharp
[assembly: FunctionsStartup(typeof(Startup))]
diff --git a/docs/machine-learning/how-to-guides/serve-model-web-api-ml-net.md b/docs/machine-learning/how-to-guides/serve-model-web-api-ml-net.md
index cfa0fd260202a..324e26d351380 100644
--- a/docs/machine-learning/how-to-guides/serve-model-web-api-ml-net.md
+++ b/docs/machine-learning/how-to-guides/serve-model-web-api-ml-net.md
@@ -61,7 +61,7 @@ You need to create some classes to define the schema of your model input and out
In your *Program.cs* file:
-1. Add the following using statements:
+1. Add the following `using` directives:
```csharp
using Microsoft.ML.Data;
@@ -83,7 +83,7 @@ In your *Program.cs* file:
**Model output**
- Once the model evaluates the input, it outputs a prediction with three properties: `Sentiment`, `Probability`, and `Score`. In this case, the `Sentiment` is the predicted sentiment of the user comment and the `Probability` and `Score` are confidence measures for the prediction.
+ Once the model evaluates the input, it outputs a prediction with three properties: `Sentiment`, `Probability`, and `Score`. In this case, the `Sentiment` is the predicted sentiment of the user comment and the `Probability` and `Score` are confidence measures for the prediction.
```csharp
public class ModelOutput
@@ -143,7 +143,7 @@ var predictionHandler =
app.MapPost("/predict", predictionHandler);
```
-The `/predict` endpoint accepts HTTP POST requests and uses the prediction engine pool to return a prediction using the provided input.
+The `/predict` endpoint accepts HTTP POST requests and uses the prediction engine pool to return a prediction using the provided input.
When finished, your *Program.cs* should look like the following:
diff --git a/docs/machine-learning/tutorials/github-issue-classification.md b/docs/machine-learning/tutorials/github-issue-classification.md
index 4a44ee749a3e7..818c30576e166 100644
--- a/docs/machine-learning/tutorials/github-issue-classification.md
+++ b/docs/machine-learning/tutorials/github-issue-classification.md
@@ -58,7 +58,7 @@ You can find the source code for this tutorial at the [dotnet/samples](https://g
### Create classes and define paths
-Add the following additional `using` statements to the top of the *Program.cs* file:
+Add the following additional `using` directives to the top of the *Program.cs* file:
[!code-csharp[AddUsings](./snippets/github-issue-classification/csharp/Program.cs#AddUsings)]
@@ -71,7 +71,7 @@ Create three global fields to hold the paths to the recently downloaded files, a
* `_trainingDataView` is the used to process the training dataset.
* `_predEngine` is the used for single predictions.
-Add the following code to the line directly below the using statements to specify those paths and the other variables:
+Add the following code to the line directly below the `using` directives to specify those paths and the other variables:
[!code-csharp[DeclareGlobalVariables](./snippets/github-issue-classification/csharp/Program.cs#DeclareGlobalVariables)]
@@ -81,7 +81,7 @@ Create some classes for your input data and predictions. Add a new class to your
1. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *GitHubIssueData.cs*. Then, select the **Add** button.
- The *GitHubIssueData.cs* file opens in the code editor. Add the following `using` statement to the top of *GitHubIssueData.cs*:
+ The *GitHubIssueData.cs* file opens in the code editor. Add the following `using` directive to the top of *GitHubIssueData.cs*:
[!code-csharp[AddUsings](./snippets/github-issue-classification/csharp/GitHubIssueData.cs#AddUsings)]
diff --git a/docs/machine-learning/tutorials/image-classification-api-transfer-learning.md b/docs/machine-learning/tutorials/image-classification-api-transfer-learning.md
index 7018aa558c54f..06c045ffc354d 100644
--- a/docs/machine-learning/tutorials/image-classification-api-transfer-learning.md
+++ b/docs/machine-learning/tutorials/image-classification-api-transfer-learning.md
@@ -123,7 +123,7 @@ In this tutorial, only bridge deck images are used.
### Create input and output classes
-1. Open the *Program.cs* file and replace the existing `using` statements at the top of the file with the following:
+1. Open the *Program.cs* file and replace the existing `using` directives at the top of the file with the following:
[!code-csharp [ProgramUsings](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ImageClassification_Binary/DeepLearning_ImageClassification/Program.cs#L1-L7)]
@@ -171,7 +171,7 @@ When training and validation data do not change often, it is good practice to ca
### Define paths and initialize variables
-1. Under the using statements, define the location of your assets, computed bottleneck values and `.pb` version of the model.
+1. Under the `using` directives, define the location of your assets, computed bottleneck values and `.pb` version of the model.
[!code-csharp [DefinePaths](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ImageClassification_Binary/DeepLearning_ImageClassification/Program.cs#L15-L17)]
diff --git a/docs/machine-learning/tutorials/image-classification.md b/docs/machine-learning/tutorials/image-classification.md
index cbde83493f58e..691b7a69f47e6 100644
--- a/docs/machine-learning/tutorials/image-classification.md
+++ b/docs/machine-learning/tutorials/image-classification.md
@@ -141,11 +141,11 @@ The training and testing images are located in the assets folders that you'll do
### Create classes and define paths
-1. Add the following additional `using` statements to the top of the *Program.cs* file:
+1. Add the following additional `using` directives to the top of the *Program.cs* file:
[!code-csharp[AddUsings](./snippets/image-classification/csharp/Program.cs#AddUsings)]
-1. Add the following code to the line right below the using statements to specify the asset paths:
+1. Add the following code to the line right below the `using` directives to specify the asset paths:
[!code-csharp[DeclareGlobalVariables](./snippets/image-classification/csharp/Program.cs#DeclareGlobalVariables)]
diff --git a/docs/machine-learning/tutorials/iris-clustering.md b/docs/machine-learning/tutorials/iris-clustering.md
index 53d01983a7137..372c75ed9878b 100644
--- a/docs/machine-learning/tutorials/iris-clustering.md
+++ b/docs/machine-learning/tutorials/iris-clustering.md
@@ -97,7 +97,7 @@ Go back to the *Program.cs* file and add two fields to hold the paths to the dat
- `_dataPath` contains the path to the file with the data set used to train the model.
- `_modelPath` contains the path to the file where the trained model is stored.
-Add the following code under the using statements to specify those paths:
+Add the following code under the `using` directives to specify those paths:
[!code-csharp[Initialize paths](./snippets/iris-clustering/csharp/Program.cs#Paths)]
diff --git a/docs/machine-learning/tutorials/movie-recommendation.md b/docs/machine-learning/tutorials/movie-recommendation.md
index 4130d7eb1a731..25a87f2aab7cb 100644
--- a/docs/machine-learning/tutorials/movie-recommendation.md
+++ b/docs/machine-learning/tutorials/movie-recommendation.md
@@ -58,7 +58,7 @@ There are several ways to approach recommendation problems, such as recommending
In **Solution Explorer**, right-click the project and select **Manage NuGet Packages**. Choose "nuget.org" as the Package source, select the **Browse** tab, search for **Microsoft.ML**, select the package in the list, and select the **Install** button. Select the **OK** button on the **Preview Changes** dialog and then select the **I Accept** button on the **License Acceptance** dialog if you agree with the license terms for the packages listed. Repeat these steps for **Microsoft.ML.Recommender**.
-5. Add the following `using` statements at the top of your *Program.cs* file:
+5. Add the following `using` directives at the top of your *Program.cs* file:
[!code-csharp[UsingStatements](./snippets/movie-recommendation/csharp/Program.cs#UsingStatements "Add necessary usings")]
@@ -119,7 +119,7 @@ Add a new class to your project:
2. In the **Add New Item dialog box**, select **Class** and change the **Name** field to *MovieRatingData.cs*. Then, select the **Add** button.
-The *MovieRatingData.cs* file opens in the code editor. Add the following `using` statement to the top of *MovieRatingData.cs*:
+The *MovieRatingData.cs* file opens in the code editor. Add the following `using` directive to the top of *MovieRatingData.cs*:
```csharp
using Microsoft.ML.Data;
diff --git a/docs/machine-learning/tutorials/object-detection-onnx.md b/docs/machine-learning/tutorials/object-detection-onnx.md
index d9e08d46eb433..0ec38e697e076 100644
--- a/docs/machine-learning/tutorials/object-detection-onnx.md
+++ b/docs/machine-learning/tutorials/object-detection-onnx.md
@@ -112,7 +112,7 @@ Now that you have a general understanding of what ONNX is and how Tiny YOLOv2 wo
### Create classes and define paths
-Open the *Program.cs* file and add the following additional `using` statements to the top of the file:
+Open the *Program.cs* file and add the following additional `using` directives to the top of the file:
[!code-csharp [ProgramUsings](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ObjectDetection_Onnx/ObjectDetectionConsoleApp/Program.cs#L1-L6)]
@@ -122,7 +122,7 @@ Next, define the paths of the various assets.
[!code-csharp [GetAbsolutePath](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ObjectDetection_Onnx/ObjectDetectionConsoleApp/Program.cs#L55-L63)]
-1. Then, below the using statements, create fields to store the location of your assets.
+1. Then, below the `using` directives, create fields to store the location of your assets.
[!code-csharp [AssetDefinition](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ObjectDetection_Onnx/ObjectDetectionConsoleApp/Program.cs#L8-L12)]
@@ -135,7 +135,7 @@ Create your input data class in the newly created *DataStructures* directory.
1. In **Solution Explorer**, right-click the *DataStructures* directory, and then select **Add** > **New Item**.
1. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *ImageNetData.cs*. Then, select the **Add** button.
- The *ImageNetData.cs* file opens in the code editor. Add the following `using` statement to the top of *ImageNetData.cs*:
+ The *ImageNetData.cs* file opens in the code editor. Add the following `using` directive to the top of *ImageNetData.cs*:
[!code-csharp [ImageNetDataUsings](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ObjectDetection_Onnx/ObjectDetectionConsoleApp/DataStructures/ImageNetData.cs#L1-L4)]
@@ -155,7 +155,7 @@ Create your prediction class in the *DataStructures* directory.
1. In **Solution Explorer**, right-click the *DataStructures* directory, and then select **Add** > **New Item**.
1. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *ImageNetPrediction.cs*. Then, select the **Add** button.
- The *ImageNetPrediction.cs* file opens in the code editor. Add the following `using` statement to the top of *ImageNetPrediction.cs*:
+ The *ImageNetPrediction.cs* file opens in the code editor. Add the following `using` directive to the top of *ImageNetPrediction.cs*:
[!code-csharp [ImageNetPredictionUsings](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ObjectDetection_Onnx/ObjectDetectionConsoleApp/DataStructures/ImageNetPrediction.cs#L1)]
@@ -203,7 +203,7 @@ The data output by the model contains coordinates and dimensions of the bounding
1. In **Solution Explorer**, right-click the *YoloParser* directory, and then select **Add** > **New Item**.
1. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *DimensionsBase.cs*. Then, select the **Add** button.
- The *DimensionsBase.cs* file opens in the code editor. Remove all `using` statements and existing class definition.
+ The *DimensionsBase.cs* file opens in the code editor. Remove all `using` directives and existing class definition.
Add the following code for the `DimensionsBase` class to the *DimensionsBase.cs* file:
@@ -221,7 +221,7 @@ Next, create a class for your bounding boxes.
1. In **Solution Explorer**, right-click the *YoloParser* directory, and then select **Add** > **New Item**.
1. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *YoloBoundingBox.cs*. Then, select the **Add** button.
- The *YoloBoundingBox.cs* file opens in the code editor. Add the following `using` statement to the top of *YoloBoundingBox.cs*:
+ The *YoloBoundingBox.cs* file opens in the code editor. Add the following `using` directive to the top of *YoloBoundingBox.cs*:
[!code-csharp [YoloBoundingBoxUsings](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ObjectDetection_Onnx/ObjectDetectionConsoleApp/YoloParser/YoloBoundingBox.cs#L1)]
@@ -248,7 +248,7 @@ Now that the classes for dimensions and bounding boxes are created, it's time to
1. In **Solution Explorer**, right-click the *YoloParser* directory, and then select **Add** > **New Item**.
1. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *YoloOutputParser.cs*. Then, select the **Add** button.
- The *YoloOutputParser.cs* file opens in the code editor. Add the following `using` statements to the top of *YoloOutputParser.cs*:
+ The *YoloOutputParser.cs* file opens in the code editor. Add the following `using` directives to the top of *YoloOutputParser.cs*:
[!code-csharp [YoloParserUsings](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ObjectDetection_Onnx/ObjectDetectionConsoleApp/YoloParser/YoloOutputParser.cs#L1-L4)]
@@ -453,7 +453,7 @@ Just like with post-processing, there are a few steps in the scoring steps. To h
1. In **Solution Explorer**, right-click the project, and then select **Add** > **New Item**.
1. In the **Add New Item** dialog box, select **Class** and change the **Name** field to *OnnxModelScorer.cs*. Then, select the **Add** button.
- The *OnnxModelScorer.cs* file opens in the code editor. Add the following `using` statements to the top of *OnnxModelScorer.cs*:
+ The *OnnxModelScorer.cs* file opens in the code editor. Add the following `using` directives to the top of *OnnxModelScorer.cs*:
[!code-csharp [ScorerUsings](~/machinelearning-samples/samples/csharp/getting-started/DeepLearning_ObjectDetection_Onnx/ObjectDetectionConsoleApp/OnnxModelScorer.cs#L1-L7)]
diff --git a/docs/machine-learning/tutorials/phone-calls-anomaly-detection.md b/docs/machine-learning/tutorials/phone-calls-anomaly-detection.md
index 56db29b26342e..a86730e1ce35a 100644
--- a/docs/machine-learning/tutorials/phone-calls-anomaly-detection.md
+++ b/docs/machine-learning/tutorials/phone-calls-anomaly-detection.md
@@ -45,7 +45,7 @@ You can find the source code for this tutorial at the [dotnet/samples](https://g
Repeat these steps for **Microsoft.ML.TimeSeries** version **1.5.2**.
-5. Add the following `using` statements at the top of your *Program.cs* file:
+5. Add the following `using` directives at the top of your *Program.cs* file:
[!code-csharp[AddUsings](./snippets/phone-calls-anomaly-detection/csharp/Program.cs#AddUsings "Add necessary usings")]
@@ -83,7 +83,7 @@ Add a new class to your project:
The *PhoneCallsData.cs* file opens in the code editor.
-3. Add the following `using` statement to the top of *PhoneCallsData.cs*:
+3. Add the following `using` directive to the top of *PhoneCallsData.cs*:
```csharp
using Microsoft.ML.Data;
@@ -97,7 +97,7 @@ Add a new class to your project:
`PhoneCallsPrediction` specifies the prediction data class. For SR-CNN detector, the prediction depends on the [detect mode](xref:Microsoft.ML.TimeSeries.SrCnnDetectMode) specified. In this sample, we select the `AnomalyAndMargin` mode. The output contains seven columns. In most cases, `IsAnomaly`, `ExpectedValue`, `UpperBoundary`, and `LowerBoundary` are informative enough. They tell you if a point is an anomaly, the expected value of the point and the lower / upper boundary region of the point.
-5. Add the following code to the line right below the using statements to specify the path to your data file:
+5. Add the following code to the line right below the `using` directives to specify the path to your data file:
[!code-csharp[Declare global variables](./snippets/phone-calls-anomaly-detection/csharp/Program.cs#DeclareGlobalVariables "Declare global variables")]
diff --git a/docs/machine-learning/tutorials/predict-prices.md b/docs/machine-learning/tutorials/predict-prices.md
index e4cfbd66ae3c4..eab052441c088 100644
--- a/docs/machine-learning/tutorials/predict-prices.md
+++ b/docs/machine-learning/tutorials/predict-prices.md
@@ -81,7 +81,7 @@ The `TaxiTripFarePrediction` class represents predicted results. It has a single
### Define data and model paths
-Add the following additional `using` statements to the top of the *Program.cs* file:
+Add the following additional `using` directives to the top of the *Program.cs* file:
[!code-csharp[AddUsings](./snippets/predict-prices/csharp/Program.cs#1 "Add necessary usings")]
diff --git a/docs/machine-learning/tutorials/sales-anomaly-detection.md b/docs/machine-learning/tutorials/sales-anomaly-detection.md
index e5cf7055f6426..4eb1b46471b94 100644
--- a/docs/machine-learning/tutorials/sales-anomaly-detection.md
+++ b/docs/machine-learning/tutorials/sales-anomaly-detection.md
@@ -45,7 +45,7 @@ You can find the source code for this tutorial at the [dotnet/samples](https://g
In Solution Explorer, right-click on your project and select **Manage NuGet Packages**. Choose "nuget.org" as the Package source, select the Browse tab, search for **Microsoft.ML** and select the **Install** button. Select the **OK** button on the **Preview Changes** dialog and then select the **I Accept** button on the **License Acceptance** dialog if you agree with the license terms for the packages listed. Repeat these steps for **Microsoft.ML.TimeSeries**.
-5. Add the following `using` statements at the top of your *Program.cs* file:
+5. Add the following `using` directives at the top of your *Program.cs* file:
[!code-csharp[AddUsings](./snippets/sales-anomaly-detection/csharp/Program.cs#AddUsings "Add necessary usings")]
@@ -81,7 +81,7 @@ Add a new class to your project:
The *ProductSalesData.cs* file opens in the code editor.
-3. Add the following `using` statement to the top of *ProductSalesData.cs*:
+3. Add the following `using` directive to the top of *ProductSalesData.cs*:
```csharp
using Microsoft.ML.Data;
@@ -100,7 +100,7 @@ Add a new class to your project:
* `_dataPath` has the path to the dataset used to train the model.
* `_docsize` has the number of records in dataset file. You'll use `_docSize` to calculate `pvalueHistoryLength`.
-6. Add the following code to the line right below the using statements to specify those paths:
+6. Add the following code to the line right below the `using` directives to specify those paths:
[!code-csharp[Declare global variables](./snippets/sales-anomaly-detection/csharp/Program.cs#DeclareGlobalVariables "Declare global variables")]
diff --git a/docs/machine-learning/tutorials/sentiment-analysis-model-builder.md b/docs/machine-learning/tutorials/sentiment-analysis-model-builder.md
index 62d944f02c552..901417c2210ee 100644
--- a/docs/machine-learning/tutorials/sentiment-analysis-model-builder.md
+++ b/docs/machine-learning/tutorials/sentiment-analysis-model-builder.md
@@ -133,7 +133,7 @@ To make a single prediction, you have to create a to return a prediction needs to be added.
-1. Open the *Index.cshtml.cs* file located in the *Pages* directory and add the following using statements:
+1. Open the *Index.cshtml.cs* file located in the *Pages* directory and add the following `using` directives:
```csharp
using Microsoft.Extensions.ML;
diff --git a/docs/machine-learning/tutorials/sentiment-analysis.md b/docs/machine-learning/tutorials/sentiment-analysis.md
index 47542e73404c4..f727f93c47c89 100644
--- a/docs/machine-learning/tutorials/sentiment-analysis.md
+++ b/docs/machine-learning/tutorials/sentiment-analysis.md
@@ -56,11 +56,11 @@ You can find the source code for this tutorial at the [dotnet/samples](https://g
### Create classes and define paths
-1. Add the following additional `using` statements to the top of the *Program.cs* file:
+1. Add the following additional `using` directives to the top of the *Program.cs* file:
[!code-csharp[AddUsings](./snippets/sentiment-analysis/csharp/Program.cs#AddUsings "Add necessary usings")]
-1. Add the following code to the line right below the `using` statements, to create a field to hold the recently downloaded dataset file path:
+1. Add the following code to the line right below the `using` directives, to create a field to hold the recently downloaded dataset file path:
[!code-csharp[Declare global variables](./snippets/sentiment-analysis/csharp/Program.cs#DeclareGlobalVariables "Declare global variables")]
@@ -70,7 +70,7 @@ You can find the source code for this tutorial at the [dotnet/samples](https://g
- In the **Add New Item** dialog box, select **Class** and change the **Name** field to *SentimentData.cs*. Then, select the **Add** button.
-1. The *SentimentData.cs* file opens in the code editor. Add the following `using` statement to the top of *SentimentData.cs*:
+1. The *SentimentData.cs* file opens in the code editor. Add the following `using` directive to the top of *SentimentData.cs*:
[!code-csharp[AddUsings](./snippets/sentiment-analysis/csharp/SentimentData.cs#AddUsings "Add necessary usings")]
diff --git a/docs/machine-learning/tutorials/text-classification-tf.md b/docs/machine-learning/tutorials/text-classification-tf.md
index fb4149be59c22..6aaf6ff5a0288 100644
--- a/docs/machine-learning/tutorials/text-classification-tf.md
+++ b/docs/machine-learning/tutorials/text-classification-tf.md
@@ -59,13 +59,13 @@ You can find the source code for this tutorial at the [dotnet/samples](https://g
3. In Solution Explorer, right-click each of the files in the `sentiment_model` directory and subdirectory and select **Properties**. Under **Advanced**, change the value of **Copy to Output Directory** to **Copy if newer**.
-### Add using statements and global variables
+### Add `using` directives and global variables
-1. Add the following additional `using` statements to the top of the *Program.cs* file:
+1. Add the following additional `using` directives to the top of the *Program.cs* file:
[!code-csharp[AddUsings](./snippets/text-classification-tf/csharp/Program.cs#AddUsings "Add necessary usings")]
-1. Create a global variable right after the using statements to hold the saved model file path.
+1. Create a global variable right after the `using` directives to hold the saved model file path.
[!code-csharp[DeclareGlobalVariables](./snippets/text-classification-tf/csharp/Program.cs#DeclareGlobalVariables "Declare global variables")]
diff --git a/docs/machine-learning/tutorials/time-series-demand-forecasting.md b/docs/machine-learning/tutorials/time-series-demand-forecasting.md
index 41ef44eab1f21..2c98ba52e9b61 100644
--- a/docs/machine-learning/tutorials/time-series-demand-forecasting.md
+++ b/docs/machine-learning/tutorials/time-series-demand-forecasting.md
@@ -90,7 +90,7 @@ The following is a sample of the data:
### Create input and output classes
-1. Open *Program.cs* file and replace the existing `using` statements with the following:
+1. Open *Program.cs* file and replace the existing `using` directives with the following:
[!code-csharp [ProgramUsings](~/machinelearning-samples/samples/csharp/getting-started/Forecasting_BikeSharingDemand/BikeDemandForecasting/Program.cs#L1-L4)]
@@ -116,7 +116,7 @@ The following is a sample of the data:
### Define paths and initialize variables
-1. Below the using statements define variables to store the location of your data, connection string, and where to save the trained model.
+1. Below the `using` directives define variables to store the location of your data, connection string, and where to save the trained model.
[!code-csharp [DefinePaths](~/machinelearning-samples/samples/csharp/getting-started/Forecasting_BikeSharingDemand/BikeDemandForecasting/Program.cs#L6-L9)]
diff --git a/docs/orleans/quickstarts/deploy-scale-orleans-on-azure.md b/docs/orleans/quickstarts/deploy-scale-orleans-on-azure.md
index 148c5fa8555e7..e5b1a33029e3c 100644
--- a/docs/orleans/quickstarts/deploy-scale-orleans-on-azure.md
+++ b/docs/orleans/quickstarts/deploy-scale-orleans-on-azure.md
@@ -60,10 +60,10 @@ The sample application is available as an Azure Developer CLI template. Through
```output
Deploying services (azd deploy)
-
+
(✓) Done: Deploying service web
- Endpoint:
-
+
SUCCESS: Your application was provisioned and deployed to Azure in 5 minutes 0 seconds.
```
@@ -173,7 +173,7 @@ Prior to using the grain, you must install the corresponding `Microsoft.Orleans.
The sample app is currently configured to create a localhost cluster and persist grains in-memory. When hosted in Azure, Orleans can be configured to use more scalable, centralized state using a data service in Azure.
-1. Add using directives for the `` and `` namespaces.
+1. Add the following `using` directives:
```csharp
using Azure.Identity;
@@ -218,7 +218,7 @@ The sample app is currently configured to create a localhost cluster and persist
{
var endpoint = new Uri(builder.Configuration["AZURE_TABLE_STORAGE_ENDPOINT"]!);
var credential = new DefaultAzureCredential();
-
+
siloBuilder
.UseAzureStorageClustering(options =>
{
@@ -266,7 +266,7 @@ The sample app is currently configured to create a localhost cluster and persist
{
var endpoint = builder.Configuration["AZURE_COSMOS_DB_NOSQL_ENDPOINT"]!;
var credential = new DefaultAzureCredential();
-
+
siloBuilder
.UseCosmosClustering(options =>
{
diff --git a/docs/standard/datetime/access-utc-and-local.md b/docs/standard/datetime/access-utc-and-local.md
index 7d0bece72ec69..e9f700bb6bce9 100644
--- a/docs/standard/datetime/access-utc-and-local.md
+++ b/docs/standard/datetime/access-utc-and-local.md
@@ -39,12 +39,6 @@ The following code uses the property rather than assigning the local time zone to a object variable. Similarly, you should always access Coordinated Universal Time through the property rather than assigning the UTC zone to a object variable. This prevents the object variable from being invalidated by a call to the method.
-## Compiling the code
-
-This example requires:
-
-- That the namespace be imported with the `using` statement (required in C# code).
-
## See also
- [Dates, times, and time zones](index.md)
diff --git a/docs/standard/datetime/let-users-resolve-ambiguous-times.md b/docs/standard/datetime/let-users-resolve-ambiguous-times.md
index 6c9283ca685b2..c09ee482f0512 100644
--- a/docs/standard/datetime/let-users-resolve-ambiguous-times.md
+++ b/docs/standard/datetime/let-users-resolve-ambiguous-times.md
@@ -42,12 +42,6 @@ The core of the example code uses an array of objects to
In this example, all references to the local time zone are made through the property; the local time zone is never assigned to an object variable. This is a recommended practice because a call to the method invalidates any objects that the local time zone is assigned to.
-## Compiling the code
-
-This example requires:
-
-- That the namespace be imported with the `using` statement (required in C# code).
-
## See also
- [Dates, times, and time zones](index.md)
diff --git a/docs/standard/datetime/resolve-ambiguous-times.md b/docs/standard/datetime/resolve-ambiguous-times.md
index d7353025c2700..9de30b32cad99 100644
--- a/docs/standard/datetime/resolve-ambiguous-times.md
+++ b/docs/standard/datetime/resolve-ambiguous-times.md
@@ -41,12 +41,6 @@ Ordinarily, an ambiguous time is handled by calling the property; the local time zone is never assigned to an object variable. This is a recommended practice because a call to the method invalidates any objects that the local time zone is assigned to.
-## Compiling the code
-
-This example requires:
-
-- That the namespace be imported with the `using` statement (required in C# code).
-
## See also
- [Dates, times, and time zones](index.md)
diff --git a/docs/standard/datetime/use-time-zones-in-arithmetic.md b/docs/standard/datetime/use-time-zones-in-arithmetic.md
index e28feeff1ce81..62e1f1dd8efd6 100644
--- a/docs/standard/datetime/use-time-zones-in-arithmetic.md
+++ b/docs/standard/datetime/use-time-zones-in-arithmetic.md
@@ -2,10 +2,10 @@
description: "Learn more about: How to: Use time zones in date and time arithmetic"
title: "How to: Use time zones in date and time arithmetic"
ms.date: "04/10/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
-helpviewer_keywords:
+helpviewer_keywords:
- "time zones [.NET], arithmetic operations"
- "arithmetic operations [.NET], dates and times"
- "dates [.NET], adding and subtracting"
@@ -48,12 +48,6 @@ The example illustrates how to perform arithmetic operations on value without first converting it to UTC, the result reflects the correct point in time but its offset does not reflect that of the designated time zone for that time.
-## Compiling the code
-
-This example requires:
-
-- That the namespace be imported with the `using` statement (required in C# code).
-
## See also
- [Dates, times, and time zones](index.md)
diff --git a/docs/standard/native-interop/pinvoke.md b/docs/standard/native-interop/pinvoke.md
index 3bab25cd88320..f14b4956e4a1f 100644
--- a/docs/standard/native-interop/pinvoke.md
+++ b/docs/standard/native-interop/pinvoke.md
@@ -16,7 +16,7 @@ Let's start from the most common example, and that is calling unmanaged function
The previous example is simple, but it does show off what's needed to invoke unmanaged functions from managed code. Let's step through the example:
-- Line #2 shows the using statement for the `System.Runtime.InteropServices` namespace that holds all the items needed.
+- Line #2 shows the `using` directive for the `System.Runtime.InteropServices` namespace that holds all the items needed.
- Line #8 introduces the attribute. This attribute tells the runtime that it should load the unmanaged binary. The string passed in is the unmanaged binary that contains the target function. Additionally, it specifies the encoding to use for marshalling the strings. Finally, it specifies that this function calls [SetLastError](/windows/desktop/api/errhandlingapi/nf-errhandlingapi-setlasterror) and that the runtime should capture that error code so the user can retrieve it via .
- Line #9 is the crux of the P/Invoke work. It defines a managed method that has the **exact same signature** as the unmanaged one. The declaration uses the `LibraryImport` attribute and the `partial` keyword to tell a compiler extension to generate code to call into the unmanaged library.
- Within the generated code and prior to .NET 7, the `DllImport` is used. This declaration uses the `extern` keyword to indicate to the runtime this is an external method, and that when you invoke it, the runtime should find it in the unmanaged binary specified in the `DllImport` attribute.
diff --git a/docs/standard/parallel-programming/how-to-cancel-a-dataflow-block.md b/docs/standard/parallel-programming/how-to-cancel-a-dataflow-block.md
index 31dc1622d11a9..2723e72e039f7 100644
--- a/docs/standard/parallel-programming/how-to-cancel-a-dataflow-block.md
+++ b/docs/standard/parallel-programming/how-to-cancel-a-dataflow-block.md
@@ -2,10 +2,10 @@
description: "Learn more about: How to: Cancel a Dataflow Block"
title: "How to: Cancel a Dataflow Block"
ms.date: "03/30/2017"
-dev_langs:
+dev_langs:
- "csharp"
- "vb"
-helpviewer_keywords:
+helpviewer_keywords:
- "Task Parallel Library, dataflows"
- "dataflow blocks, canceling in TPL"
- "TPL dataflow library,canceling dataflow blocks"
@@ -13,84 +13,84 @@ ms.assetid: fbddda0d-da3b-4ec8-a1d6-67ab8573fcd7
---
# How to: Cancel a Dataflow Block
-This document demonstrates how to enable cancellation in your application. This example uses Windows Forms to show where work items are active in a dataflow pipeline and also the effects of cancellation.
+This document demonstrates how to enable cancellation in your application. This example uses Windows Forms to show where work items are active in a dataflow pipeline and also the effects of cancellation.
[!INCLUDE [tpl-install-instructions](../../../includes/tpl-install-instructions.md)]
-
-## To Create the Windows Forms Application
-
-1. Create a C# or Visual Basic **Windows Forms Application** project. In the following steps, the project is named `CancellationWinForms`.
-
-2. On the form designer for the main form, Form1.cs (Form1.vb for Visual Basic), add a control.
-
-3. Add a control to the control. Set the property to and the property to **Add Work Items**.
-
-4. Add a second control to the control. Set the property to , the property to **Cancel**, and the property to `False`.
-
-5. Add four objects to the control.
-
-## Creating the Dataflow Pipeline
-
- This section describes how to create the dataflow pipeline that processes work items and updates the progress bars.
-
-### To Create the Dataflow Pipeline
-
-1. In your project, add a reference to System.Threading.Tasks.Dataflow.dll.
-
-2. Ensure that Form1.cs (Form1.vb for Visual Basic) contains the following `using` statements (`Imports` in Visual Basic).
-
+
+## To Create the Windows Forms Application
+
+1. Create a C# or Visual Basic **Windows Forms Application** project. In the following steps, the project is named `CancellationWinForms`.
+
+2. On the form designer for the main form, Form1.cs (Form1.vb for Visual Basic), add a control.
+
+3. Add a control to the control. Set the property to and the property to **Add Work Items**.
+
+4. Add a second control to the control. Set the property to , the property to **Cancel**, and the property to `False`.
+
+5. Add four objects to the control.
+
+## Creating the Dataflow Pipeline
+
+ This section describes how to create the dataflow pipeline that processes work items and updates the progress bars.
+
+### To Create the Dataflow Pipeline
+
+1. In your project, add a reference to System.Threading.Tasks.Dataflow.dll.
+
+2. Ensure that Form1.cs (Form1.vb for Visual Basic) contains the following `using` directives (`Imports` in Visual Basic).
+
[!code-csharp[TPLDataflow_CancellationWinForms#1](../../../samples/snippets/csharp/VS_Snippets_Misc/tpldataflow_cancellationwinforms/cs/cancellationwinforms/form1.cs#1)]
- [!code-vb[TPLDataflow_CancellationWinForms#1](../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpldataflow_cancellationwinforms/vb/cancellationwinforms/form1.vb#1)]
-
-3. Add the `WorkItem` class as an inner type of the `Form1` class.
-
+ [!code-vb[TPLDataflow_CancellationWinForms#1](../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpldataflow_cancellationwinforms/vb/cancellationwinforms/form1.vb#1)]
+
+3. Add the `WorkItem` class as an inner type of the `Form1` class.
+
[!code-csharp[TPLDataflow_CancellationWinForms#2](../../../samples/snippets/csharp/VS_Snippets_Misc/tpldataflow_cancellationwinforms/cs/cancellationwinforms/form1.cs#2)]
- [!code-vb[TPLDataflow_CancellationWinForms#2](../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpldataflow_cancellationwinforms/vb/cancellationwinforms/form1.vb#2)]
-
-4. Add the following data members to the `Form1` class.
-
+ [!code-vb[TPLDataflow_CancellationWinForms#2](../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpldataflow_cancellationwinforms/vb/cancellationwinforms/form1.vb#2)]
+
+4. Add the following data members to the `Form1` class.
+
[!code-csharp[TPLDataflow_CancellationWinForms#3](../../../samples/snippets/csharp/VS_Snippets_Misc/tpldataflow_cancellationwinforms/cs/cancellationwinforms/form1.cs#3)]
- [!code-vb[TPLDataflow_CancellationWinForms#3](../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpldataflow_cancellationwinforms/vb/cancellationwinforms/form1.vb#3)]
-
-5. Add the following method, `CreatePipeline`, to the `Form1` class.
-
+ [!code-vb[TPLDataflow_CancellationWinForms#3](../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpldataflow_cancellationwinforms/vb/cancellationwinforms/form1.vb#3)]
+
+5. Add the following method, `CreatePipeline`, to the `Form1` class.
+
[!code-csharp[TPLDataflow_CancellationWinForms#4](../../../samples/snippets/csharp/VS_Snippets_Misc/tpldataflow_cancellationwinforms/cs/cancellationwinforms/form1.cs#4)]
- [!code-vb[TPLDataflow_CancellationWinForms#4](../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpldataflow_cancellationwinforms/vb/cancellationwinforms/form1.vb#4)]
-
- Because the `incrementProgress` and `decrementProgress` dataflow blocks act on the user interface, it is important that these actions occur on the user-interface thread. To accomplish this, during construction these objects each provide an object that has the