Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .openpublishing.redirection.framework.json
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,61 @@
"redirect_url": "/dotnet/standard/native-interop/runtime-callable-wrapper",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/default-marshaling-behavior.md",
"redirect_url": "/dotnet/framework/interop/default-marshalling-behavior",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/default-marshaling-for-arrays.md",
"redirect_url": "/dotnet/framework/interop/default-marshalling-for-arrays",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/default-marshaling-for-objects.md",
"redirect_url": "/dotnet/framework/interop/default-marshalling-for-objects",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/default-marshaling-for-strings.md",
"redirect_url": "/dotnet/framework/interop/default-marshalling-for-strings",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/interop-marshaling.md",
"redirect_url": "/dotnet/framework/interop/interop-marshalling",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/marshaling-a-delegate-as-a-callback-method.md",
"redirect_url": "/dotnet/framework/interop/marshalling-a-delegate-as-a-callback-method",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/marshaling-classes-structures-and-unions.md",
"redirect_url": "/dotnet/framework/interop/marshalling-classes-structures-and-unions",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/marshaling-data-with-com-interop.md",
"redirect_url": "/dotnet/framework/interop/marshalling-data-with-com-interop",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/marshaling-data-with-platform-invoke.md",
"redirect_url": "/dotnet/framework/interop/marshalling-data-with-platform-invoke",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/marshaling-different-types-of-arrays.md",
"redirect_url": "/dotnet/framework/interop/marshalling-different-types-of-arrays",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/interop/marshaling-strings.md",
"redirect_url": "/dotnet/framework/interop/marshalling-strings",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/framework/mef/composition-analysis-tool-mefx.md",
"redirect_url": "/previous-versions/dotnet/framework/mef/composition-analysis-tool-mefx",
Expand Down
14 changes: 7 additions & 7 deletions .openpublishing.redirection.standard.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,23 +527,23 @@
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/standard/native-interop/customize-parameter-marshalling.md",
"redirect_url": "/dotnet/standard/native-interop/customize-parameter-marshaling",
"source_path_from_root": "/docs/standard/native-interop/customize-parameter-marshaling.md",
"redirect_url": "/dotnet/standard/native-interop/customize-parameter-marshalling",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/standard/native-interop/customize-struct-marshalling.md",
"redirect_url": "/dotnet/standard/native-interop/customize-struct-marshaling",
"source_path_from_root": "/docs/standard/native-interop/customize-struct-marshaling.md",
"redirect_url": "/dotnet/standard/native-interop/customize-struct-marshalling",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/standard/native-interop/type-marshalling.md",
"redirect_url": "/dotnet/standard/native-interop/type-marshaling",
"source_path_from_root": "/docs/standard/native-interop/type-marshaling.md",
"redirect_url": "/dotnet/standard/native-interop/type-marshalling",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/standard/parallel-processing-and-concurrency.md",
"redirect_url": "/dotnet/standard/asynchronous-programming-patterns",
"redirect_url": "/dotnet/standard/asynchronous-programming-patterns"
},
{
"source_path_from_root": "/docs/standard/parallel-programming/how-to-write-a-parallel-foreach-loop-with-thread-local-variables.md",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In previous .NET versions, some Windows Forms types were decorated as visible to
- Removal of `ComVisible(true)` from some non-public code: The only potential consumer would be the new Visual Studio designer, but without a GUID specified, it's unlikely that it's still needed.
- Removal of `ComVisible(true)` from some arbitrary public designer classes: The old Visual Studio designer may have been using COM interop to talk to these classes. However, the old designer doesn't support .NET Core, so few people would need these as `ComVisible`.
- `IWin32Window` defined the same GUID that was defined in .NET Framework, which has dangerous consequences. If you require interop with .NET Framework, use `ComImport`.
- The WinForms managed `IDataObject` was made `ComVisible`. This is not required, there is a separate `ComImport` interface declaration for `IDataObject` COM interop. It's counterproductive to have the managed `IDataObject` be `ComVisible`, since no TLB is provided and marshaling will always fail. Also, the GUID was not specified and differed from .NET Framework, so its unlikely that removing an undocumented IID will affect customers negatively.
- The WinForms managed `IDataObject` was made `ComVisible`. This is not required, there is a separate `ComImport` interface declaration for `IDataObject` COM interop. It's counterproductive to have the managed `IDataObject` be `ComVisible`, since no TLB is provided and marshalling will always fail. Also, the GUID was not specified and differed from .NET Framework, so its unlikely that removing an undocumented IID will affect customers negatively.
- Removal of `ComVisible(false)`: Those are placed in seemingly arbitrary places and are redundant when the default is to not expose classes to COM interop.

## Version introduced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ There are two design patterns for solving these type conversion issues.

1. Use common shared types. This shared type can either be a primitive runtime type, or it can involve creating a new shared type in a shared assembly. Often the shared type is an [interface](../../csharp/language-reference/keywords/interface.md) defined in an application assembly. For more information, read about [how dependencies are shared](#how-are-dependencies-shared).

2. Use marshaling techniques to convert from one type to another.
2. Use marshalling techniques to convert from one type to another.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ms.assetid: bc76efe0-4304-4449-8c11-950667aa8ac9

Accessing a member on 'member' may cause a runtime exception because it is a field of a marshal-by-reference class

This warning occurs when you try to call a method, property, or indexer on a member of a class that derives from <xref:System.MarshalByRefObject>, and the member is a value type. Objects that inherit from `MarshalByRefObject` are typically intended to be marshaled by reference across an application domain. If any code ever attempts to directly access the value-type member of such an object across an application domain, a runtime <xref:System.InvalidOperationException> will occur. To resolve the warning, first copy the member into a local variable and call the method on that variable.
This warning occurs when you try to call a method, property, or indexer on a member of a class that derives from <xref:System.MarshalByRefObject>, and the member is a value type. Objects that inherit from `MarshalByRefObject` are typically intended to be marshalled by reference across an application domain. If any code ever attempts to directly access the value-type member of such an object across an application domain, a runtime <xref:System.InvalidOperationException> will occur. To resolve the warning, first copy the member into a local variable and call the method on that variable.

The following sample generates CS1690:

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/unsafe-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ A `struct` can contain an embedded array in unsafe code. In the following exampl

:::code language="csharp" source="snippets/unsafe-code/FixedKeywordExamples.cs" ID="7":::

The size of the 128 element `char` array is 256 bytes. Fixed size [char](builtin-types/char.md) buffers always take 2 bytes per character, regardless of the encoding. This array size is the same even when char buffers are marshaled to API methods or structs with `CharSet = CharSet.Auto` or `CharSet = CharSet.Ansi`. For more information, see <xref:System.Runtime.InteropServices.CharSet>.
The size of the 128 element `char` array is 256 bytes. Fixed size [char](builtin-types/char.md) buffers always take 2 bytes per character, regardless of the encoding. This array size is the same even when char buffers are marshalled to API methods or structs with `CharSet = CharSet.Auto` or `CharSet = CharSet.Ansi`. For more information, see <xref:System.Runtime.InteropServices.CharSet>.

The preceding example demonstrates accessing `fixed` fields without pinning, which is available starting with C# 7.3.

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/misc/cs0197.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ms.assetid: 2b5b1b8d-ce13-4bd7-b80a-abb80e9f79ad

Passing 'argument' as ref or out or taking its address may cause a runtime exception because it is a field of a marshal-by-reference class

Any class that derives, directly or indirectly, from <xref:System.MarshalByRefObject> is a marshal-by-reference class. Such a class can be marshaled by reference across process and machine boundaries. Thus, instances of this class could be proxies to remote objects. You cannot pass a field of a proxy object as [ref](../language-reference/keywords/ref.md) or [out](../language-reference/keywords/out-parameter-modifier.md). So, you cannot pass fields of such a class as `ref` or `out`, unless the instance is [this](../language-reference/keywords/this.md), which can not be a proxy object.
Any class that derives, directly or indirectly, from <xref:System.MarshalByRefObject> is a marshal-by-reference class. Such a class can be marshalled by reference across process and machine boundaries. Thus, instances of this class could be proxies to remote objects. You cannot pass a field of a proxy object as [ref](../language-reference/keywords/ref.md) or [out](../language-reference/keywords/out-parameter-modifier.md). So, you cannot pass fields of such a class as `ref` or `out`, unless the instance is [this](../language-reference/keywords/this.md), which can not be a proxy object.

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ A method with the attribute <xref:System.Runtime.InteropServices.DllImportAttrib
More than one attribute can be placed on a declaration as the following example shows:

[!code-csharp[Including the interop namespace](~/samples/snippets/csharp/attributes/AttributesOverview.cs#3)]
[!code-csharp[Declaring two way marshaling for arguments](~/samples/snippets/csharp/attributes/AttributesOverview.cs#4)]
[!code-csharp[Declaring two way marshalling for arguments](~/samples/snippets/csharp/attributes/AttributesOverview.cs#4)]

Some attributes can be specified more than once for a given entity. An example of such a multiuse attribute is <xref:System.Diagnostics.ConditionalAttribute>:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ The **Open Files** dialog box is filtered to show only files that have a .wav ex
- [C# Programming Guide](../index.md)
- [Interoperability Overview](interoperability-overview.md)
- [A Closer Look at Platform Invoke](../../../framework/interop/consuming-unmanaged-dll-functions.md#a-closer-look-at-platform-invoke)
- [Marshaling Data with Platform Invoke](../../../framework/interop/marshaling-data-with-platform-invoke.md)
- [Marshalling Data with Platform Invoke](../../../framework/interop/marshalling-data-with-platform-invoke.md)
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ For more information, see [Consuming Unmanaged DLL Functions](../../../framework
- [Improving Interop Performance](/previous-versions/msp-n-p/ff647812(v=pandp.10))
- [Introduction to Interoperability between COM and .NET](/office/client-developer/outlook/pia/introduction-to-interoperability-between-com-and-net)
- [Introduction to COM Interop in Visual Basic](../../../visual-basic/programming-guide/com-interop/introduction-to-com-interop.md)
- [Marshaling between Managed and Unmanaged Code](../../../framework/interop/interop-marshaling.md)
- [Marshalling between Managed and Unmanaged Code](../../../framework/interop/interop-marshalling.md)
- [Interoperating with Unmanaged Code](../../../framework/interop/index.md)
- [C# Programming Guide](../index.md)
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Defines one or more switches used by the <xref:System.AppContext> class to provi
|`Switch.System.Net.`<br/>`DontEnableSchUseStrongCrypto`|Controls whether the <xref:System.Net.ServicePointManager?displayProperty=nameWithType> and <xref:System.Net.Security.SslStream?displayProperty=nameWithType> classes can use the SSL 3.0 protocol. For more information, see [Mitigation: TLS Protocols](../../../migration-guide/mitigation-tls-protocols.md).|.NET Framework 4.6|
|`Switch.System.Net.`<br/>`DontEnableSystemDefaultTlsVersions`|Disables SystemDefault TLS versions reverting back to a default of Tls12, Tls11, Tls.|.NET Framework 4.7|
|`Switch.System.Net.`<br/>`DontEnableTlsAlerts`|Disables SslStream TLS server-side Alerts.|.NET Framework 4.7|
|`Switch.System.Runtime.InteropServices.`<br/>`DoNotMarshalOutByrefSafeArrayOnInvoke`|Controls whether ByRef SafeArray parameters on COM interop events marshal back to native code (`false`) or whether marshaling back to native code is disabled (`true`).|.NET Framework 4.8|
|`Switch.System.Runtime.InteropServices.`<br/>`DoNotMarshalOutByrefSafeArrayOnInvoke`|Controls whether ByRef SafeArray parameters on COM interop events marshal back to native code (`false`) or whether marshalling back to native code is disabled (`true`).|.NET Framework 4.8|
|`Switch.System.Runtime.Serialization.`<br/>`DoNotUseECMAScriptV6EscapeControlCharacter` |Controls whether the [DataContractJsonSerializer](xref:System.Runtime.Serialization.Json.DataContractJsonSerializer) serializes some control characters based on the ECMAScript V6 and V8 standards. For more information, see [Mitigation: Serialization of Control Characters with the DataContractJsonSerializer](../../../migration-guide/mitigation-serialization-control-characters.md)| .NET Framework 4.7 |
|`Switch.System.Runtime.Serialization.`<br/>`DoNotUseTimeZoneInfo`|Controls whether the <xref:System.Runtime.Serialization.Json.DataContractJsonSerializer> supports multiple adjustments or only a single adjustment for a time zone. If `true`, it uses the <xref:System.TimeZoneInfo> type to serialize and deserialize date and time data; otherwise, it uses the <xref:System.TimeZone> type, which does not support multiple adjustment rules.|.NET Framework 4.6.2|
|`Switch.System.Runtime.Serialization.UseNewMaxArraySize`|Controls whether <xref:System.Runtime.Serialization.ObjectManager?displayProperty=nameWithType> uses a larger array size during object serialization and deserialization. Set this switch to `true` to improve the performance of serialization and deserialization of large object graphs by types such as <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter>. |.NET Framework 4.7.2|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The following sections describe attributes, child elements, and parent elements.

|Value|Description|
|-----------|-----------------|
|`0`|The runtime uses the faster interop marshaling architecture introduced in the .NET Framework 4, which does not detect and fix incorrect platform invoke declarations. This is the default.|
|`0`|The runtime uses the faster interop marshalling architecture introduced in the .NET Framework 4, which does not detect and fix incorrect platform invoke declarations. This is the default.|
|`1`|The runtime uses slower transitions that detect and fix incorrect platform invoke declarations.|

### Child Elements
Expand All @@ -51,9 +51,9 @@ None.

## Remarks

This element enables you to trade faster interop marshaling for run-time resilience against incorrect platform invoke declarations.
This element enables you to trade faster interop marshalling for run-time resilience against incorrect platform invoke declarations.

Starting with the .NET Framework 4, a streamlined interop marshaling architecture provides a significant performance improvement for transitions from managed code to unmanaged code. In earlier versions of the .NET Framework, the marshaling layer detected incorrect platform invoke declarations on 32-bit platforms and automatically fixed the stack. The new marshaling architecture eliminates this step. As a result, transitions are very fast, but an incorrect platform invoke declaration can cause a program failure.
Starting with the .NET Framework 4, a streamlined interop marshalling architecture provides a significant performance improvement for transitions from managed code to unmanaged code. In earlier versions of the .NET Framework, the marshalling layer detected incorrect platform invoke declarations on 32-bit platforms and automatically fixed the stack. The new marshalling architecture eliminates this step. As a result, transitions are very fast, but an incorrect platform invoke declaration can cause a program failure.

To make it easy to detect incorrect declarations during development, the Visual Studio debugging experience has been improved. The [pInvokeStackImbalance](../../../debug-trace-profile/pinvokestackimbalance-mda.md) managed debugging assistant (MDA) notifies you of incorrect platform invoke declarations when your application is running with the debugger attached.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following sections describe attributes, child elements, and parent elements.

| Attribute | Description |
| ----------------- | ----------- |
| `processMessages` | A Boolean value that specifies whether messages should be marshaled between SOAP message versions. |
| `processMessages` | A Boolean value that specifies whether messages should be marshalled between SOAP message versions. |

### Child elements

Expand Down
2 changes: 1 addition & 1 deletion docs/framework/data/adonet/ole-db-data-type-mappings.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The following table shows the inferred .NET Framework type for data types from t
|adUserDefined|DBTYPE_UDT|not supported||
|adVarNumeric|DBTYPE_VARNUMERIC|not supported||

\* For the OLE DB types `DBTYPE_IUNKNOWN` and `DBTYPE_IDISPATCH`, the object reference is a marshaled representation of the pointer.
\* For the OLE DB types `DBTYPE_IUNKNOWN` and `DBTYPE_IDISPATCH`, the object reference is a marshalled representation of the pointer.

## See also

Expand Down
2 changes: 1 addition & 1 deletion docs/framework/data/adonet/secure-data-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ To write secure ADO.NET code, you have to understand the security mechanisms ava
|Resource|Description|
|--------------|-----------------|
|[Interoperating with Unmanaged Code](../../interop/index.md)|Contains topics describing how to expose COM components to the .NET Framework and how to expose .NET Framework components to COM.|
|[Advanced COM Interoperability](/previous-versions/dotnet/netframework-4.0/bd9cdfyx(v=vs.100))|Contains advanced topics such as primary interop assemblies, threading and custom marshaling.|
|[Advanced COM Interoperability](/previous-versions/dotnet/netframework-4.0/bd9cdfyx(v=vs.100))|Contains advanced topics such as primary interop assemblies, threading and custom marshalling.|

## See also

Expand Down
Loading