Skip to content

Latest commit

 

History

History
66 lines (51 loc) · 3.3 KB

File metadata and controls

66 lines (51 loc) · 3.3 KB
title description ms.date ms.topic f1_keywords helpviewer_keywords author ms.author manager ms.subservice dev_langs monikerRange
CA1406: Avoid Int64 arguments for Visual Basic 6 clients
A type that is specifically marked as visible to Component Object Model (COM) declares a member that takes a System.Int64 argument.
11/04/2016
reference
AvoidInt64ArgumentsForVB6Clients
CA1406
AvoidInt64ArgumentsForVB6Clients
CA1406
mikejo5000
mikejo
jmartens
code-analysis
CSharp
VB
vs-2019

CA1406: Avoid Int64 arguments for Visual Basic 6 clients

Item Value
RuleId CA1406
Category Microsoft.Interoperability
Breaking change Breaking

Cause

A type that is specifically marked as visible to Component Object Model (COM) declares a member that takes a xref:System.Int64?displayProperty=fullName argument.

Note

This rule has been deprecated. For more information, see Deprecated rules.

Rule description

Visual Basic 6 COM clients cannot access 64-bit integers.

By default, the following are visible to COM: assemblies, public types, public instance members in public types, and all members of public value types. However, to reduce false positives, this rule requires the COM visibility of the type to be explicitly stated; the containing assembly must be marked with the xref:System.Runtime.InteropServices.ComVisibleAttribute?displayProperty=fullName set to false and the type must be marked with the xref:System.Runtime.InteropServices.ComVisibleAttribute set to true.

How to fix violations

To fix a violation of this rule for a parameter whose value can always be expressed as a 32-bit integral, change the parameter type to xref:System.Int32?displayProperty=fullName. If the value of the parameter might be larger than can be expressed as a 32-bit integral, change the parameter type to xref:System.Decimal?displayProperty=fullName. Note that both xref:System.Single?displayProperty=fullName and xref:System.Double?displayProperty=fullName lose precision at the upper ranges of the xref:System.Int64 data type. If the member is not meant to be visible to COM, mark it with the xref:System.Runtime.InteropServices.ComVisibleAttribute set to false.

When to suppress warnings

It is safe to suppress a warning from this rule if it is certain that Visual Basic 6 COM clients will not access the type.

Example

The following example shows a type that violates the rule.

:::code language="csharp" source="../snippets/csharp/VS_Snippets_CodeAnalysis/FxCop.Interoperability.LongArgument/cs/FxCop.Interoperability.LongArgument.cs" id="Snippet1":::

:::code language="vb" source="../snippets/visualbasic/VS_Snippets_CodeAnalysis/FxCop.Interoperability.LongArgument/vb/FxCop.Interoperability.LongArgument.vb" id="Snippet1":::

Related rules

CA1413: Avoid non-public fields in COM visible value types

CA1407: Avoid static members in COM visible types

CA1017: Mark assemblies with ComVisibleAttribute

See also