183 instantiations of InvalidCastException
Aspire.Confluent.Kafka (1)
src\Vendoring\OpenTelemetry.Instrumentation.ConfluentKafka\Shared\Guard.cs (1)
179throw new InvalidCastException($"Cannot cast '{paramName}' from '{value?.GetType().ToString() ?? "null"}' to '{typeof(T)}'");
Aspire.Dashboard.Tests (2)
Telemetry\DashboardTelemetrySenderTests.cs (1)
99throw new InvalidCastException($"Unexpected path: {request.RequestUri}");
Telemetry\DashboardTelemetryServiceTests.cs (1)
140throw new InvalidCastException($"Unexpected path: {request.RequestUri}");
Aspire.Hosting.Kubernetes (1)
Resources\Int32OrStringV1.cs (1)
70value.Number ?? throw new InvalidCastException("The specified value is not an Int32.");
Aspire.Hosting.RemoteHost (5)
Ats\AtsMarshaller.cs (5)
760throw new InvalidCastException($"Value cannot be converted to {targetType.Name}."); 764throw new InvalidCastException($"Value cannot be converted to {targetType.Name}."); 793throw new InvalidCastException($"Value cannot be converted to {targetType.Name}."); 799throw new InvalidCastException($"Value cannot be converted to {targetType.Name}."); 806throw new InvalidCastException($"Value cannot be converted to {targetType.Name}.");
Aspire.Hosting.RemoteHost.Tests (1)
CapabilityDispatcherTests.cs (1)
144throw new InvalidCastException("Cannot cast to expected type");
Aspire.StackExchange.Redis (1)
src\Vendoring\OpenTelemetry.Instrumentation.StackExchangeRedis\Shared\Guard.cs (1)
209? throw new InvalidCastException($"Cannot cast '{paramName}' from '{value?.GetType().ToString() ?? "null"}' to '{typeof(T)}'")
Crossgen2Tasks (1)
CommonFilePulledFromSdkRepo\MessageLevel.cs (1)
26=> level >= 0 ? (MessageImportance)level : throw new InvalidCastException();
dotnet-svcutil-lib (19)
FrameworkFork\Microsoft.Xml\Xml\BinaryXml\XmlBinaryReader.cs (7)
1120throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Boolean")); 1210throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "DateTime")); 1305throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Double")); 1400throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Float")); 1495throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Decimal")); 1590throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Int32")); 1685throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Int64"));
FrameworkFork\Microsoft.Xml\Xml\schema\XmlValueConverter.cs (9)
564return new InvalidCastException(string.Format(ResXml.XmlConvert_TypeBadMapping, XmlTypeName, sourceType.Name)); 566return new InvalidCastException(string.Format(ResXml.XmlConvert_TypeBadMapping2, XmlTypeName, sourceType.Name, destinationType.Name)); 724throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeNoNamespace, value, prefix)); 729throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeNoNamespace, value, prefix)); 855throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeNoPrefix, qname.ToString(), qname.Namespace)); 2913throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeToString, XmlTypeName, sourceType.Name)); 2916throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeFromString, XmlTypeName, destinationType.Name)); 3660return new InvalidCastException(string.Format(ResXml.XmlConvert_TypeListBadMapping, XmlTypeName, sourceType.Name)); 3662return new InvalidCastException(string.Format(ResXml.XmlConvert_TypeListBadMapping2, XmlTypeName, sourceType.Name, destinationType.Name));
FrameworkFork\Microsoft.Xml\Xml\Serialization\XmlSerializationReader.cs (3)
1414return new InvalidCastException(string.Format(ResXml.XmlInvalidNullCast, type.FullName)); 1416return new InvalidCastException(string.Format(ResXml.XmlInvalidCast, value.GetType().FullName, type.FullName)); 1418return new InvalidCastException(string.Format(ResXml.XmlInvalidCastWithId, value.GetType().FullName, type.FullName, id));
Microsoft.AspNetCore.Components.Forms (1)
FieldIdentifier.cs (1)
290throw new InvalidCastException($"Unable to cast object of type '{value.GetType()}' to type '{expression.Type}'.");
Microsoft.AspNetCore.DataProtection (1)
TypeExtensions.cs (1)
26throw new InvalidCastException(Resources.FormatTypeExtensions_BadCast(
Microsoft.Data.Analysis (1)
DataFrame.cs (1)
390throw new InvalidCastException(String.Format(Strings.BadColumnCastDuringGrouping, columnName, column.DataType, typeof(TKey)));
Microsoft.Diagnostics.DataContractReader.Legacy (10)
ClrDataFrame.cs (1)
463throw new InvalidCastException(); // E_NOINTERFACE
ClrDataMethodInstance.cs (3)
411throw new InvalidCastException(); 511throw new InvalidCastException(); 560throw new InvalidCastException(); // E_NOINTERFACE
ClrDataValue.cs (5)
112throw new InvalidCastException(); // E_NOINTERFACE 145throw new InvalidCastException(); // E_NOINTERFACE 176throw new InvalidCastException(); // E_NOINTERFACE 462throw new InvalidCastException(); 521throw new InvalidCastException();
SOSDacImpl.IXCLRDataProcess.cs (1)
336throw new InvalidCastException();
Microsoft.DotNet.ApiCompat.Task (1)
src\sdk\src\Tasks\Common\MessageLevel.cs (1)
26=> level >= 0 ? (MessageImportance)level : throw new InvalidCastException();
Microsoft.Extensions.Http.Resilience.Tests (3)
Polly\HttpCircuitBreakerStrategyOptionsTests.cs (1)
22new object[] { new InvalidCastException(), false },
Polly\HttpClientResiliencePredicatesTests.cs (1)
19new object[] { new InvalidCastException(), false },
Polly\HttpRetryStrategyOptionsTests.cs (1)
24new object[] { new InvalidCastException(), null!, false },
Microsoft.Extensions.VectorData.Abstractions (2)
ProviderServices\Filter\FilterTranslatorBase.cs (1)
225throw new InvalidCastException($"Property '{propertyModel.ModelName}' is being cast to type '{convert.Type.Name}', but its configured type is '{propertyModel.Type.Name}'.");
ProviderServices\PropertyModel.cs (1)
131throw new InvalidCastException($"Property '{ModelName}' has a value of type '{value.GetType().Name}', but its configured type is '{propertyType.Name}'.");
Microsoft.Maui.Controls (1)
DependencyResolver.cs (1)
35 throw new InvalidCastException("Resolved instance is not of the correct type.");
Microsoft.NET.Build.Extensions.Tasks (1)
src\sdk\src\Tasks\Common\MessageLevel.cs (1)
26=> level >= 0 ? (MessageImportance)level : throw new InvalidCastException();
Microsoft.NET.Build.Tasks (1)
src\sdk\src\Tasks\Common\MessageLevel.cs (1)
26=> level >= 0 ? (MessageImportance)level : throw new InvalidCastException();
Microsoft.Private.Windows.Core (5)
System\Value.cs (1)
80throw new InvalidCastException($"{from?.Name ?? "<null>"} cannot be cast to {to.Name}");
Windows\Win32\Foundation\HandleRef.cs (2)
53throw new InvalidCastException(); 64throw new InvalidCastException();
Windows\Win32\System\Variant\VARIANT.cs (2)
967=> value.vt == VT_UNKNOWN ? value.data.punkVal : throw new InvalidCastException(); 982private static T ThrowInvalidCast<T>() => throw new InvalidCastException();
Microsoft.TemplateEngine.Orchestrator.RunnableProjects (3)
Macros\BaseGeneratedSymbolMacro.cs (2)
21throw new InvalidCastException($"Couldn't cast the {nameof(rawConfig)} as {nameof(IGeneratedSymbolConfig)}."); 58throw new InvalidCastException($"Couldn't cast the {nameof(config)} as {typeof(T)}.");
Macros\BaseMacro.cs (1)
22throw new InvalidCastException($"Couldn't cast the {nameof(config)} as {typeof(T).Name}.");
Microsoft.VisualBasic.Core (6)
Microsoft\VisualBasic\CompilerServices\ExceptionUtils.vb (1)
245Return New InvalidCastException(Description)
Microsoft\VisualBasic\CompilerServices\NewLateBinding.vb (2)
1394Throw New InvalidCastException(errorMessage) 1470Throw New InvalidCastException(errorMessage)
Microsoft\VisualBasic\CompilerServices\Operators.Resolution.vb (1)
217Throw New InvalidCastException(errorMessage)
Microsoft\VisualBasic\CompilerServices\OverloadResolution.vb (1)
2575Return New InvalidCastException(message)
Microsoft\VisualBasic\CompilerServices\Utils.vb (1)
90Throw New Global.System.InvalidCastException()
NuGet.ProjectModel (4)
JsonTextReaderExtensions.cs (2)
33throw new InvalidCastException(); 208throw new InvalidCastException();
src\nuget-client\build\Shared\Utf8JsonReaderExtensions.cs (1)
29throw new InvalidCastException();
src\nuget-client\build\Shared\Utf8JsonStreamReader.cs (1)
257throw new InvalidCastException();
PresentationFramework (2)
MS\Internal\Controls\ConnectionPointCookie.cs (2)
49ex = new InvalidCastException(SR.Format(SR.AxNoSinkImplementation, eventInterface.Name)); 65ex = new InvalidCastException(SR.AxNoConnectionPointContainer);
System.Collections.Concurrent (1)
System\Collections\Concurrent\ConcurrentBag.cs (1)
303throw new InvalidCastException(e.Message, e);
System.CommandLine (1)
Binding\ArgumentConverter.cs (1)
33throw new InvalidCastException();
System.ComponentModel.Annotations (3)
System\ComponentModel\DataAnnotations\LengthAttribute.cs (1)
67throw new InvalidCastException(SR.Format(SR.LengthAttribute_InvalidValueType, value.GetType()));
System\ComponentModel\DataAnnotations\MaxLengthAttribute.cs (1)
84throw new InvalidCastException(SR.Format(SR.LengthAttribute_InvalidValueType, value.GetType()));
System\ComponentModel\DataAnnotations\MinLengthAttribute.cs (1)
67throw new InvalidCastException(SR.Format(SR.LengthAttribute_InvalidValueType, value.GetType()));
System.Data.Common (2)
src\runtime\src\libraries\Common\src\System\Data\Common\AdapterUtil.cs (1)
104InvalidCastException e = new InvalidCastException(error, inner);
System\Data\DataSetUtil.cs (1)
35return new InvalidCastException(message);
System.Data.Odbc (3)
Common\System\Data\Common\AdapterUtil.Odbc.cs (2)
70InvalidCastException e = new InvalidCastException(); 406e = new InvalidCastException(message, inner);
src\runtime\src\libraries\Common\src\System\Data\Common\AdapterUtil.cs (1)
104InvalidCastException e = new InvalidCastException(error, inner);
System.Data.OleDb (3)
System\Data\Common\AdapterUtil.cs (3)
124InvalidCastException e = new InvalidCastException(error, inner); 154InvalidCastException e = new InvalidCastException(); 729e = new InvalidCastException(message, inner);
System.Drawing.Common (1)
System\Drawing\Printing\TriState.cs (1)
41value.IsDefault ? throw new InvalidCastException(SR.TriStateCompareError) : value == True;
System.Linq.Expressions (4)
System\Linq\Expressions\Error.cs (2)
96return new InvalidCastException(Strings.DynamicObjectResultNotAssignable(p0, p1, p2, p3)); 103return new InvalidCastException(Strings.DynamicBinderResultNotAssignable(p0, p1, p2));
System\Linq\Expressions\Interpreter\TypeOperations.cs (2)
308throw new InvalidCastException(); 313throw new InvalidCastException();
System.Private.CoreLib (54)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Array.cs (1)
563throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Boolean.cs (2)
333throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Boolean", "Char")); 393throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Boolean", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Byte.cs (1)
243throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Byte", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Char.cs (5)
586throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Boolean")); 636throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Single")); 641throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Double")); 646throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Decimal")); 651throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Convert.cs (8)
137throw new InvalidCastException(SR.InvalidCast_IConvertible); 161TypeCode.DBNull => throw new InvalidCastException(SR.InvalidCast_DBNull), 162TypeCode.Empty => throw new InvalidCastException(SR.InvalidCast_Empty), 214throw new InvalidCastException(SR.InvalidCast_DBNull); 216throw new InvalidCastException(SR.InvalidCast_Empty); 218throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, value.GetType().FullName, targetType.FullName)); 236throw new InvalidCastException(SR.InvalidCast_CannotCastNullToValueType); 247throw new InvalidCastException(SR.InvalidCast_IConvertible);
src\runtime\src\libraries\System.Private.CoreLib\src\System\DateTime.cs (1)
1964private static InvalidCastException InvalidCast(string to) => new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, nameof(DateTime), to));
src\runtime\src\libraries\System.Private.CoreLib\src\System\DBNull.cs (14)
44throw new InvalidCastException(SR.InvalidCast_FromDBNull); 49throw new InvalidCastException(SR.InvalidCast_FromDBNull); 54throw new InvalidCastException(SR.InvalidCast_FromDBNull); 59throw new InvalidCastException(SR.InvalidCast_FromDBNull); 64throw new InvalidCastException(SR.InvalidCast_FromDBNull); 69throw new InvalidCastException(SR.InvalidCast_FromDBNull); 74throw new InvalidCastException(SR.InvalidCast_FromDBNull); 79throw new InvalidCastException(SR.InvalidCast_FromDBNull); 84throw new InvalidCastException(SR.InvalidCast_FromDBNull); 89throw new InvalidCastException(SR.InvalidCast_FromDBNull); 94throw new InvalidCastException(SR.InvalidCast_FromDBNull); 99throw new InvalidCastException(SR.InvalidCast_FromDBNull); 104throw new InvalidCastException(SR.InvalidCast_FromDBNull); 109throw new InvalidCastException(SR.InvalidCast_FromDBNull);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Decimal.cs (2)
1036throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Decimal", "Char")); 1096throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Decimal", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Double.cs (2)
457throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Double", "Char")); 517throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Double", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Enum.cs (1)
2191DateTime IConvertible.ToDateTime(IFormatProvider? provider) => throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Enum", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int16.cs (1)
246throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int16", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int32.cs (1)
261throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int32", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int64.cs (1)
258throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int64", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\ComWrappers.cs (1)
1686throw new InvalidCastException();
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshal.cs (1)
793return new System.InvalidCastException();
src\runtime\src\libraries\System.Private.CoreLib\src\System\SByte.cs (1)
249throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "SByte", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Single.cs (2)
450throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Single", "Char")); 510throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Single", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt16.cs (1)
240throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt16", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt32.cs (1)
256throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt32", "DateTime"));
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt64.cs (1)
255throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt64", "DateTime"));
System\Array.NativeAot.cs (2)
411throw new InvalidCastException(SR.Format(SR.Arg_ObjObjEx, value.GetType(), Type.GetTypeFromHandle(new RuntimeTypeHandle(pElementEEType)))); 430throw new InvalidCastException(SR.InvalidCast_StoreArrayElement);
System\InvokeUtils.cs (1)
439return new InvalidCastException(SR.InvalidCast_StoreArrayElement);
System\Runtime\InteropServices\IDynamicInterfaceCastable.cs (1)
62throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, instance.GetType(), Type.GetTypeFromMethodTable(interfaceType)));
System\RuntimeExceptionHelpers.cs (1)
90return new InvalidCastException();
System\TypedReference.cs (1)
88static void ThrowInvalidCastException() => throw new InvalidCastException();
System.Private.Windows.Core (5)
System\Value.cs (1)
80throw new InvalidCastException($"{from?.Name ?? "<null>"} cannot be cast to {to.Name}");
Windows\Win32\Foundation\HandleRef.cs (2)
53throw new InvalidCastException(); 64throw new InvalidCastException();
Windows\Win32\System\Variant\VARIANT.cs (2)
967=> value.vt == VT_UNKNOWN ? value.data.punkVal : throw new InvalidCastException(); 982private static T ThrowInvalidCast<T>() => throw new InvalidCastException();
System.Private.Xml (19)
System\Xml\BinaryXml\XmlBinaryReader.cs (7)
1109throw new InvalidCastException(SR.Format(SR.XmlBinary_CastNotSupported, _token, "Boolean")); 1199throw new InvalidCastException(SR.Format(SR.XmlBinary_CastNotSupported, _token, "DateTime")); 1294throw new InvalidCastException(SR.Format(SR.XmlBinary_CastNotSupported, _token, "Double")); 1389throw new InvalidCastException(SR.Format(SR.XmlBinary_CastNotSupported, _token, "Float")); 1484throw new InvalidCastException(SR.Format(SR.XmlBinary_CastNotSupported, _token, "Decimal")); 1579throw new InvalidCastException(SR.Format(SR.XmlBinary_CastNotSupported, _token, "Int32")); 1674throw new InvalidCastException(SR.Format(SR.XmlBinary_CastNotSupported, _token, "Int64"));
System\Xml\Schema\XmlValueConverter.cs (9)
478return new InvalidCastException(SR.Format(SR.XmlConvert_TypeBadMapping, XmlTypeName, sourceType.Name)); 480return new InvalidCastException(SR.Format(SR.XmlConvert_TypeBadMapping2, XmlTypeName, sourceType.Name, destinationType.Name)); 639throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeNoNamespace, value, prefix)); 644throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeNoNamespace, value, prefix)); 770throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeNoPrefix, qname, qname.Namespace)); 2493throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeToString, XmlTypeName, sourceType.Name)); 2496throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeFromString, XmlTypeName, destinationType.Name)); 3128return new InvalidCastException(SR.Format(SR.XmlConvert_TypeListBadMapping, XmlTypeName, sourceType.Name)); 3130return new InvalidCastException(SR.Format(SR.XmlConvert_TypeListBadMapping2, XmlTypeName, sourceType.Name, destinationType.Name));
System\Xml\Serialization\XmlSerializationReader.cs (3)
1361return new InvalidCastException(SR.Format(SR.XmlInvalidNullCast, type.FullName)); 1363return new InvalidCastException(SR.Format(SR.XmlInvalidCast, value.GetType().FullName, type.FullName)); 1365return new InvalidCastException(SR.Format(SR.XmlInvalidCastWithId, value.GetType().FullName, type.FullName, id));
System.Reflection.Metadata (1)
System\Reflection\Throw.cs (1)
17throw new InvalidCastException();
System.Runtime.InteropServices (1)
System\Runtime\InteropServices\Marshalling\ComInterfaceMarshaller.cs (1)
82throw new InvalidCastException($"Unable to cast the provided managed object to a COM interface with ID '{TargetInterfaceIID.GetValueOrDefault():B}'");
System.Text.Json (1)
System\Text\Json\ThrowHelper.Serialization.cs (1)
58throw new InvalidCastException(SR.Format(SR.DeserializeUnableToAssignValue, typeOfValue, declaredType));
System.Text.RegularExpressions (1)
System\Text\RegularExpressions\Regex.Timeout.cs (1)
118throw new InvalidCastException(SR.Format(SR.IllegalDefaultRegexMatchTimeoutInAppDomain, DefaultMatchTimeout_ConfigKeyName, defaultTimeout));
System.Windows.Forms (10)
System\Windows\Forms\ActiveX\AxHost.ConnectionPointCookie.cs (2)
29throw new InvalidCastException(SR.AXNoConnectionPointContainer); 39throw new InvalidCastException(string.Format(SR.AXNoSinkImplementation, eventInterface.Name));
System\Windows\Forms\Controls\DataGridView\DataGridView.Methods.cs (1)
2653throw new InvalidCastException(SR.DataGridView_InvalidEditingControl);
System\Windows\Forms\Controls\DataGridView\DataGridViewButtonColumn.cs (1)
37throw new InvalidCastException(string.Format(SR.DataGridViewTypeColumn_WrongCellTemplateType, "System.Windows.Forms.DataGridViewButtonCell"));
System\Windows\Forms\Controls\DataGridView\DataGridViewCheckBoxColumn.cs (1)
38throw new InvalidCastException(string.Format(SR.DataGridViewTypeColumn_WrongCellTemplateType, "System.Windows.Forms.DataGridViewCheckBoxCell"));
System\Windows\Forms\Controls\DataGridView\DataGridViewComboBoxColumn.cs (1)
75throw new InvalidCastException(string.Format(SR.DataGridViewTypeColumn_WrongCellTemplateType, "System.Windows.Forms.DataGridViewComboBoxCell"));
System\Windows\Forms\Controls\DataGridView\DataGridViewImageColumn.cs (1)
45throw new InvalidCastException(string.Format(SR.DataGridViewTypeColumn_WrongCellTemplateType, "System.Windows.Forms.DataGridViewImageCell"));
System\Windows\Forms\Controls\DataGridView\DataGridViewLinkColumn.cs (1)
85throw new InvalidCastException(string.Format(SR.DataGridViewTypeColumn_WrongCellTemplateType, "System.Windows.Forms.DataGridViewLinkCell"));
System\Windows\Forms\Controls\DataGridView\DataGridViewTextBoxColumn.cs (1)
28throw new InvalidCastException(string.Format(SR.DataGridViewTypeColumn_WrongCellTemplateType, "System.Windows.Forms.DataGridViewTextBoxCell"));
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\PropertyGridView.DropDownHolder.cs (1)
350throw new InvalidCastException(string.Format(SR.PropertyGridViewEditorCreatedInvalidObject, createType));
357 references to InvalidCastException
Aspire.Hosting (1)
Ats\CollectionExports.cs (1)
175catch (Exception ex) when (ex is FormatException or InvalidCastException or OverflowException or ArgumentException)
Aspire.Hosting.Kubernetes (1)
Resources\Int32OrStringV1.cs (1)
68/// <exception cref="InvalidCastException">Thrown if the value isn't a valid integer.</exception>
Aspire.Hosting.RemoteHost (1)
Ats\CapabilityDispatcher.cs (1)
585catch (InvalidCastException ex)
Aspire.Hosting.RemoteHost.Tests (5)
AtsMarshallerTests.cs (5)
272Assert.Throws<InvalidCastException>(() => AtsMarshaller.ConvertPrimitive(value!, typeof(int))); 288Assert.Throws<InvalidCastException>(() => AtsMarshaller.ConvertPrimitive(value, targetType)); 295Assert.Throws<InvalidCastException>(() => AtsMarshaller.ConvertPrimitive(value, targetType)); 608Assert.Throws<InvalidCastException>(() => AtsMarshaller.ConvertPrimitive(value!, typeof(long))); 656Assert.Throws<InvalidCastException>(() => AtsMarshaller.ConvertPrimitive(value!, typeof(decimal)));
dotnet (1)
Telemetry\ExternalTelemetryProperties.cs (1)
36Debug.Assert(e is ArgumentException | e is SecurityException | e is InvalidCastException);
dotnet-aot (1)
src\sdk\src\Cli\dotnet\Telemetry\ExternalTelemetryProperties.cs (1)
36Debug.Assert(e is ArgumentException | e is SecurityException | e is InvalidCastException);
dotnet-svcutil-lib (38)
FrameworkFork\Microsoft.Xml\Xml\BinaryXml\XmlBinaryReader.cs (9)
1139catch (InvalidCastException e) 1229catch (InvalidCastException e) 1324catch (InvalidCastException e) 1419catch (InvalidCastException e) 1514catch (InvalidCastException e) 1609catch (InvalidCastException e) 1704catch (InvalidCastException e) 1744catch (InvalidCastException e) 1791catch (InvalidCastException e)
FrameworkFork\Microsoft.Xml\Xml\Core\XmlReader.cs (1)
400catch (InvalidCastException e)
FrameworkFork\Microsoft.Xml\Xml\Core\XmlReaderAsync.cs (1)
79catch (InvalidCastException e)
FrameworkFork\Microsoft.Xml\Xml\Core\XsdValidatingReader.cs (18)
464catch (InvalidCastException e) 497catch (InvalidCastException e) 530catch (InvalidCastException e) 563catch (InvalidCastException e) 596catch (InvalidCastException e) 629catch (InvalidCastException e) 662catch (InvalidCastException e) 695catch (InvalidCastException e) 741catch (InvalidCastException e) 787catch (InvalidCastException e) 822catch (InvalidCastException e) 857catch (InvalidCastException e) 892catch (InvalidCastException e) 927catch (InvalidCastException e) 962catch (InvalidCastException e) 997catch (InvalidCastException e) 1028catch (InvalidCastException e) 1074catch (InvalidCastException e)
FrameworkFork\Microsoft.Xml\Xml\Core\XsdValidatingReaderAsync.cs (4)
64catch (InvalidCastException e) 113catch (InvalidCastException e) 159catch (InvalidCastException e) 209catch (InvalidCastException e)
FrameworkFork\Microsoft.Xml\Xml\schema\DatatypeImplementation.cs (3)
619catch (InvalidCastException e) 1108catch (InvalidCastException e) 1352catch (InvalidCastException e)
FrameworkFork\Microsoft.Xml\Xml\Serialization\XmlSerializationReader.cs (1)
1647catch (InvalidCastException)
FrameworkFork\System.ServiceModel\System\ServiceModel\Description\WsdlImporter.cs (1)
635catch (InvalidCastException)
GenerateDocumentationAndConfigFiles (7)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.AspNetCore.DataProtection (1)
TypeExtensions.cs (1)
16/// Throws <see cref="InvalidCastException"/> if <paramref name="implementationType"/>
Microsoft.AspNetCore.Diagnostics.Middleware (1)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\Validators.g.cs (1)
324catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
Microsoft.AspNetCore.HeaderParsing (1)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\Validators.g.cs (1)
137catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
Microsoft.Build (14)
BackEnd\TaskExecutionHost\TaskExecutionHost.cs (3)
1087if (ex is InvalidCastException || // invalid type 1338catch (InvalidCastException e) 1613if (ex is InvalidCastException || // invalid type
Evaluation\Expander.Function.cs (1)
1042catch (InvalidCastException)
Instance\HostServices.cs (1)
97catch (Exception ex) when (ex is COMException || ex is InvalidCastException)
Instance\TaskRegistry.cs (1)
1562catch (InvalidCastException e)
Logging\LoggerDescription.cs (1)
226catch (InvalidCastException e)
src\5057ed6cf5d6323b\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\msbuild\artifacts\.packages\microsoft.codeanalysis.collections\5.0.0-1.25277.114\contentFiles\cs\net9.0\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.Build.Framework (3)
ExceptionHandling.cs (2)
140|| e is InvalidCastException 195if (e is InvalidCastException
ValueTypeParser.cs (1)
116catch (Exception ex) when (ex is FormatException || ex is InvalidCastException || ex is OverflowException || ex is ArgumentException || ex is NotSupportedException)
Microsoft.CodeAnalysis (9)
Desktop\AssemblyVersion.cs (1)
106/// <exception cref="InvalidCastException">Major, minor, build or revision number are less than 0 or greater than 0xFFFF.</exception>
Generated\Operations.Generated.cs (1)
729/// False if the conversion will fail with a <see cref="InvalidCastException" /> at runtime if the cast fails. This is true for C#'s
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.Analyzers (7)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.AnalyzerUtilities (7)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.CodeStyle (7)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.CSharp (2)
CSharpExtensions.cs (1)
783/// <exception cref="InvalidCastException">If the <see cref="IConversionOperation"/> was not created from CSharp code.</exception>
Syntax\CSharpSyntaxTree.cs (1)
111/// <exception cref="InvalidCastException">Throws this exception if <see cref="SyntaxTree.HasCompilationUnitRoot"/> is false.</exception>
Microsoft.CodeAnalysis.Extensions.Package (7)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.NetAnalyzers (1)
Microsoft.NetCore.Analyzers\Performance\ConstantExpectedAnalyzer.UnmanagedHelper.cs (1)
251=> ex is FormatException or InvalidCastException or OverflowException or ArgumentNullException;
Microsoft.CodeAnalysis.ResxSourceGenerator (7)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.Workspaces (7)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.Data.Analysis.Tests (1)
DataFrameGroupByTests.cs (1)
106Assert.Throws<InvalidCastException>(() => df.GroupBy<double>("Tens"));
Microsoft.Extensions.AI.Abstractions (1)
AdditionalPropertiesDictionary{TValue}.cs (1)
177catch (Exception e) when (e is ArgumentException or FormatException or InvalidCastException or OverflowException)
Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization (1)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\Validators.g.cs (1)
208catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
Microsoft.Extensions.Diagnostics.Probes (1)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\Validators.g.cs (1)
163catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
Microsoft.Extensions.Diagnostics.Testing (1)
Logging\FakeLogRecord.cs (1)
64/// <exception cref="InvalidCastException">The state object is not compatible with supported logging model and is not a read-only list.</exception>
Microsoft.Extensions.Http.Diagnostics (1)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\Validators.g.cs (1)
211catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
Microsoft.Extensions.Http.Resilience (1)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\Validators.g.cs (1)
899catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
Microsoft.Extensions.Telemetry (1)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\Validators.g.cs (1)
219catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
Microsoft.Maui.Controls (3)
BindingExpression.cs (1)
373 catch (InvalidCastException)
BindingExpressionHelper.cs (1)
51 catch (Exception ex) when (ex is InvalidCastException || ex is FormatException || ex is InvalidOperationException || ex is OverflowException)
NameScopeExtensions.cs (1)
16 catch (InvalidCastException ice) when (ResourceLoader.ExceptionHandler2 != null)
Microsoft.Private.Windows.Core (3)
System\Private\Windows\Nrbf\SerializationRecordExtensions.cs (2)
33catch (Exception ex) when (ex is ArgumentException or InvalidCastException or ArithmeticException or IOException or TargetInvocationException) 48catch (Exception ex) when (ex is KeyNotFoundException or InvalidCastException)
System\Value.cs (1)
1037/// <exception cref="InvalidCastException">
Microsoft.VisualBasic.Core (2)
Microsoft\VisualBasic\CompilerServices\ObjectFlowControl.vb (1)
378Catch ex As InvalidCastException
Microsoft\VisualBasic\FileIO\FileSystem.vb (1)
1334TypeOf ex Is InvalidCastException), "Unexpected exception: " & ex.ToString())
Microsoft.Win32.Registry (1)
Microsoft\Win32\RegistryKey.cs (1)
1357catch (Exception exc) when (exc is OverflowException || exc is InvalidOperationException || exc is FormatException || exc is InvalidCastException)
Mono.Cecil (5)
Mono.Collections.Generic\Collection.cs (5)
77 } catch (InvalidCastException) { 274 } catch (InvalidCastException) { 295 } catch (InvalidCastException) { 309 } catch (InvalidCastException) { 320 } catch (InvalidCastException) {
mscorlib (1)
src\runtime\src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
305[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.InvalidCastException))]
netstandard (1)
netstandard.cs (1)
881[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.InvalidCastException))]
PresentationCore (25)
System\Windows\FreezableCollection.cs (1)
494catch (InvalidCastException e)
System\Windows\Generated\TextDecorationCollection.cs (1)
406catch (InvalidCastException e)
System\Windows\Input\Stylus\Wisp\PenThreadWorker.cs (1)
1136|| e is InvalidCastException);
System\Windows\Media\Animation\Generated\TimelineCollection.cs (1)
405catch (InvalidCastException e)
System\Windows\Media\Effects\Generated\BitmapEffectCollection.cs (1)
408catch (InvalidCastException e)
System\Windows\Media\Generated\DoubleCollection.cs (1)
380catch (InvalidCastException e)
System\Windows\Media\Generated\DrawingCollection.cs (1)
427catch (InvalidCastException e)
System\Windows\Media\Generated\GeneralTransformCollection.cs (1)
415catch (InvalidCastException e)
System\Windows\Media\Generated\GeometryCollection.cs (1)
427catch (InvalidCastException e)
System\Windows\Media\Generated\GradientStopCollection.cs (1)
415catch (InvalidCastException e)
System\Windows\Media\Generated\Int32Collection.cs (1)
380catch (InvalidCastException e)
System\Windows\Media\Generated\PathFigureCollection.cs (1)
416catch (InvalidCastException e)
System\Windows\Media\Generated\PathSegmentCollection.cs (1)
415catch (InvalidCastException e)
System\Windows\Media\Generated\PointCollection.cs (1)
380catch (InvalidCastException e)
System\Windows\Media\Generated\TextEffectCollection.cs (1)
415catch (InvalidCastException e)
System\Windows\Media\Generated\TransformCollection.cs (1)
427catch (InvalidCastException e)
System\Windows\Media\Generated\VectorCollection.cs (1)
380catch (InvalidCastException e)
System\Windows\Media3D\Generated\GeneralTransform3DCollection.cs (1)
413catch (InvalidCastException e)
System\Windows\Media3D\Generated\MaterialCollection.cs (1)
425catch (InvalidCastException e)
System\Windows\Media3D\Generated\Model3DCollection.cs (1)
425catch (InvalidCastException e)
System\Windows\Media3D\Generated\Point3DCollection.cs (1)
378catch (InvalidCastException e)
System\Windows\Media3D\Generated\Transform3DCollection.cs (1)
425catch (InvalidCastException e)
System\Windows\Media3D\Generated\Vector3DCollection.cs (1)
378catch (InvalidCastException e)
System\Windows\Media3D\Visual3DCollection.cs (1)
172catch (InvalidCastException e)
System\Windows\Nrbf\SerializationRecordExtensions.cs (1)
22catch (Exception ex) when (ex is KeyNotFoundException or InvalidCastException)
PresentationFramework (11)
MS\Internal\IO\Packaging\PackageFilter.cs (2)
285catch(InvalidCastException) 382catch (InvalidCastException)
System\Windows\Controls\ItemsControl.cs (1)
3523catch (System.InvalidCastException)
System\Windows\Controls\Primitives\DocumentViewerBase.cs (1)
1533catch (InvalidCastException) { }
System\Windows\Documents\MsSpellCheckLib\SpellCheckerFactory\SpellCheckerFactory.cs (1)
152catch (InvalidCastException icex)
System\Windows\Documents\MsSpellCheckLib\Utils\ChangeNotifyWrapper.cs (1)
69catch (InvalidCastException)
System\Windows\Documents\WinRTSpellerInterop.cs (1)
45when (ex is InvalidCastException || ex is COMException )
System\Windows\Shell\WindowChrome.cs (1)
273catch (InvalidCastException)
System\Windows\Standard\ErrorCodes.cs (2)
114catch (InvalidCastException) 351catch (InvalidCastException)
System\Windows\Standard\NativeMethods.cs (1)
2038catch (InvalidCastException)
Roslyn.Diagnostics.Analyzers (7)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
System.Collections (5)
System\Collections\Generic\SortedDictionary.cs (4)
326catch (InvalidCastException) 331catch (InvalidCastException) 355catch (InvalidCastException) 360catch (InvalidCastException)
System\Collections\Generic\SortedList.cs (1)
625catch (InvalidCastException)
System.Collections.Concurrent (1)
System\Collections\Concurrent\BlockingCollection.cs (1)
1585catch (InvalidCastException)
System.Collections.Immutable (1)
System\Collections\Immutable\ImmutableArray_1.Minimal.cs (1)
347/// <exception cref="InvalidCastException">Thrown if the cast is illegal.</exception>
System.CommandLine (2)
ParseResult.cs (2)
142/// <exception cref="InvalidCastException">The parsed result cannot be cast to <typeparamref name="T"/>.</exception> 171/// <exception cref="InvalidCastException">The parsed result cannot be cast to <typeparamref name="T"/>.</exception>
System.ComponentModel.Annotations (2)
System\ComponentModel\DataAnnotations\CustomValidationAttribute.cs (1)
338catch (InvalidCastException)
System\ComponentModel\DataAnnotations\RangeAttribute.cs (1)
152catch (InvalidCastException)
System.ComponentModel.Composition (8)
System\ComponentModel\Composition\CatalogReflectionContextAttribute.cs (1)
34catch (InvalidCastException invalidCastException)
System\ComponentModel\Composition\CompositionContractMismatchException.cs (1)
77/// <exception cref="InvalidCastException">
System\ComponentModel\Composition\ImportCardinalityMismatchException.cs (1)
80/// <exception cref="InvalidCastException">
System\ComponentModel\Composition\MetadataViewGenerator.cs (3)
269proxyCtorIL.BeginCatchBlock(typeof(InvalidCastException)); 293proxyCtorIL.BeginCatchBlock(typeof(InvalidCastException)); 346proxyCtorIL.BeginCatchBlock(typeof(InvalidCastException));
System\ComponentModel\Composition\MetadataViewProvider.cs (1)
100if (ex.InnerException!.GetType() == typeof(InvalidCastException))
System\ComponentModel\Composition\Primitives\ComposablePartException.cs (1)
47/// <exception cref="InvalidCastException">
System.ComponentModel.TypeConverter (4)
System\ComponentModel\BindingList.cs (1)
489catch (InvalidCastException)
System\ComponentModel\TypeDescriptor.cs (3)
2102catch (InvalidCastException) 2115catch (InvalidCastException) 2128catch (InvalidCastException)
System.Data.Common (15)
src\runtime\src\libraries\Common\src\System\Data\Common\AdapterUtil.cs (4)
97internal static InvalidCastException InvalidCast(string error) 102internal static InvalidCastException InvalidCast(string error, Exception? inner) 104InvalidCastException e = new InvalidCastException(error, inner); 323internal static InvalidCastException CollectionInvalidType(Type collection, Type itemType, object invalidValue)
System\Data\Common\DbConnectionStringBuilder.cs (1)
351catch (InvalidCastException)
System\Data\Common\DbConnectionStringCommon.cs (1)
19catch (InvalidCastException e)
System\Data\DataColumn.cs (2)
535catch (InvalidCastException ex) 689catch (InvalidCastException ex)
System\Data\DataSetUtil.cs (1)
33internal static InvalidCastException InvalidCast(string message)
System\Data\Filter\BinaryNode.cs (1)
266catch (System.InvalidCastException e)
System\Data\Filter\ConstNode.cs (5)
154catch (System.InvalidCastException e) 174catch (System.InvalidCastException e) 232catch (System.InvalidCastException e) 253catch (System.InvalidCastException e) 274catch (System.InvalidCastException e)
System.Data.Odbc (11)
Common\System\Data\Common\AdapterUtil.Odbc.cs (3)
68internal static InvalidCastException InvalidCast() 70InvalidCastException e = new InvalidCastException(); 404else if (inner is InvalidCastException)
Common\System\Data\Common\DbConnectionStringCommon.cs (4)
188catch (InvalidCastException e) 227catch (InvalidCastException e) 239catch (InvalidCastException e) 251catch (InvalidCastException e)
src\runtime\src\libraries\Common\src\System\Data\Common\AdapterUtil.cs (4)
97internal static InvalidCastException InvalidCast(string error) 102internal static InvalidCastException InvalidCast(string error, Exception? inner) 104InvalidCastException e = new InvalidCastException(error, inner); 323internal static InvalidCastException CollectionInvalidType(Type collection, Type itemType, object invalidValue)
System.Data.OleDb (15)
DbConnectionStringCommon.cs (3)
156catch (InvalidCastException e) 168catch (InvalidCastException e) 180catch (InvalidCastException e)
OleDb_Util.cs (2)
258internal static InvalidCastException ConversionRequired() 262internal static InvalidCastException CantConvertValue()
OleDbConnectionString.cs (1)
410catch (InvalidCastException e)
OleDbDataReader.cs (1)
1708catch (System.InvalidCastException e)
OleDbEnumerator.cs (1)
56catch (InvalidCastException)
System\Data\Common\AdapterUtil.cs (7)
118internal static InvalidCastException InvalidCast(string error) 122internal static InvalidCastException InvalidCast(string error, Exception? inner) 124InvalidCastException e = new InvalidCastException(error, inner); 152internal static InvalidCastException InvalidCast() 154InvalidCastException e = new InvalidCastException(); 465internal static InvalidCastException CollectionInvalidType(Type collection, Type itemType, object invalidValue) 727else if (inner is InvalidCastException)
System.Diagnostics.PerformanceCounter (2)
System\Diagnostics\PerformanceCounterLib.cs (2)
1070catch (InvalidCastException) 1338catch (InvalidCastException e)
System.DirectoryServices (2)
System\DirectoryServices\ActiveDirectory\ActiveDirectorySchemaClass.cs (1)
117catch (InvalidCastException)
System\DirectoryServices\ActiveDirectory\ActiveDirectorySchemaProperty.cs (1)
170catch (InvalidCastException)
System.Linq.Expressions (6)
System\Dynamic\Utils\CachedReflectionInfo.cs (1)
18s_InvalidCastException_Ctor_String ??= typeof(InvalidCastException).GetConstructor(new Type[] { typeof(string) })!;
System\Linq\Expressions\Error.cs (2)
94internal static InvalidCastException DynamicObjectResultNotAssignable(object? p0, object? p1, object? p2, object? p3) 101internal static InvalidCastException DynamicBinderResultNotAssignable(object? p0, object? p1, object? p2)
System\Runtime\CompilerServices\ReadOnlyCollectionBuilder.cs (3)
278catch (InvalidCastException) 310catch (InvalidCastException) 340catch (InvalidCastException)
System.Management (4)
System\Management\WMIGenerator.cs (4)
1666catch (System.InvalidCastException) 1698catch (System.InvalidCastException) 1728catch (System.InvalidCastException) 1760catch (System.InvalidCastException)
System.Private.CoreLib (14)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Generic\Dictionary.cs (4)
1782catch (InvalidCastException) 1787catch (InvalidCastException) 1819catch (InvalidCastException) 1824catch (InvalidCastException)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Generic\List.cs (3)
184catch (InvalidCastException) 231catch (InvalidCastException) 798catch (InvalidCastException)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\ObjectModel\Collection.cs (3)
254catch (InvalidCastException) 295catch (InvalidCastException) 337catch (InvalidCastException)
src\runtime\src\libraries\System.Private.CoreLib\src\System\DateTime.cs (1)
1964private static InvalidCastException InvalidCast(string to) => new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, nameof(DateTime), to));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\IDynamicInterfaceCastable.cs (1)
29/// true and this function returns false, then <see cref="InvalidCastException" />
System\InvokeUtils.cs (1)
437private static InvalidCastException CreateChangeTypeInvalidCastException()
System\Reflection\Runtime\TypeInfos\RuntimeTypeInfo.InvokeMember.cs (1)
182catch (InvalidCastException)
System.Private.Windows.Core (3)
System\Private\Windows\Nrbf\SerializationRecordExtensions.cs (2)
33catch (Exception ex) when (ex is ArgumentException or InvalidCastException or ArithmeticException or IOException or TargetInvocationException) 48catch (Exception ex) when (ex is KeyNotFoundException or InvalidCastException)
System\Value.cs (1)
1037/// <exception cref="InvalidCastException">
System.Private.Xml (39)
System\Xml\BinaryXml\XmlBinaryReader.cs (9)
1128catch (InvalidCastException e) 1218catch (InvalidCastException e) 1313catch (InvalidCastException e) 1408catch (InvalidCastException e) 1503catch (InvalidCastException e) 1598catch (InvalidCastException e) 1693catch (InvalidCastException e) 1733catch (InvalidCastException e) 1780catch (InvalidCastException e)
System\Xml\Core\XmlReader.cs (1)
339catch (InvalidCastException e)
System\Xml\Core\XmlReaderAsync.cs (1)
68catch (InvalidCastException e)
System\Xml\Core\XsdValidatingReader.cs (18)
476catch (InvalidCastException e) 510catch (InvalidCastException e) 544catch (InvalidCastException e) 578catch (InvalidCastException e) 612catch (InvalidCastException e) 646catch (InvalidCastException e) 681catch (InvalidCastException e) 716catch (InvalidCastException e) 762catch (InvalidCastException e) 808catch (InvalidCastException e) 843catch (InvalidCastException e) 878catch (InvalidCastException e) 913catch (InvalidCastException e) 948catch (InvalidCastException e) 983catch (InvalidCastException e) 1018catch (InvalidCastException e) 1049catch (InvalidCastException e) 1096catch (InvalidCastException e)
System\Xml\Core\XsdValidatingReaderAsync.cs (4)
61catch (InvalidCastException e) 112catch (InvalidCastException e) 160catch (InvalidCastException e) 212catch (InvalidCastException e)
System\Xml\Schema\DataTypeImplementation.cs (3)
605catch (InvalidCastException e) 1073catch (InvalidCastException e) 1328catch (InvalidCastException e)
System\Xml\Schema\XmlValueConverter.cs (1)
3125private new InvalidCastException CreateInvalidClrMappingException(Type sourceType, Type destinationType)
System\Xml\Serialization\XmlSerializationReader.cs (2)
1580catch (InvalidCastException) 5241WriteCatchException(typeof(InvalidCastException));
System.Resources.Extensions (2)
System\Resources\Extensions\BinaryFormat\BinaryFormattedObject.cs (2)
50catch (Exception ex) when (ex is ArgumentException or InvalidCastException or ArithmeticException or IOException) 71catch (Exception ex) when (ex is ArgumentException or InvalidCastException or ArithmeticException or IOException)
System.Runtime (1)
src\runtime\artifacts\obj\System.Runtime\Release\net11.0\System.Runtime.Forwards.cs (1)
286[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.InvalidCastException))]
System.ServiceModel.Primitives (2)
System\IdentityModel\Tokens\X509AsymmetricSecurityKey.cs (2)
256catch (InvalidCastException e) 331catch (InvalidCastException e)
System.Speech (1)
Internal\SapiInterop\SapiRecognizer.cs (1)
89catch (InvalidCastException)
System.Text.Json (10)
System\Text\Json\Serialization\JsonSerializer.Read.HandleMetadata.cs (1)
575catch (InvalidCastException)
System\Text\Json\Serialization\JsonSerializer.Write.ByteArray.cs (1)
88/// <exception cref="InvalidCastException">
System\Text\Json\Serialization\JsonSerializer.Write.Document.cs (1)
85/// <exception cref="InvalidCastException">
System\Text\Json\Serialization\JsonSerializer.Write.Element.cs (1)
85/// <exception cref="InvalidCastException">
System\Text\Json\Serialization\JsonSerializer.Write.Node.cs (1)
86/// <exception cref="InvalidCastException">
System\Text\Json\Serialization\JsonSerializer.Write.Pipe.cs (1)
83/// <exception cref="InvalidCastException">
System\Text\Json\Serialization\JsonSerializer.Write.Stream.cs (2)
207/// <exception cref="InvalidCastException"> 232/// <exception cref="InvalidCastException">
System\Text\Json\Serialization\JsonSerializer.Write.String.cs (1)
100/// <exception cref="InvalidCastException">
System\Text\Json\Serialization\JsonSerializer.Write.Utf8JsonWriter.cs (1)
99/// <exception cref="InvalidCastException">
System.Windows.Forms (5)
System\Windows\Forms\Controls\Labels\LinkArea.LinkAreaConverter.cs (1)
129catch (InvalidCastException invalidCast)
System\Windows\Forms\Controls\MonthCalendar\SelectionRangeConverter.cs (1)
148catch (InvalidCastException invalidCast)
System\Windows\Forms\DataBinding\ListBindingConverter.cs (1)
91catch (InvalidCastException invalidCast)
System\Windows\Forms\Internal\Formatter.cs (1)
388catch (InvalidCastException ex)
System\Windows\Forms\Panels\TableLayoutPanel\TableLayoutPanelCellPositionTypeConverter.cs (1)
86catch (InvalidCastException invalidCast)
System.Windows.Forms.Design (1)
System\ComponentModel\Design\Serialization\DesignerSerializationManager.cs (1)
329catch (InvalidCastException)
System.Windows.Forms.Primitives (1)
System\Windows\Forms\PaddingConverter.cs (1)
99catch (InvalidCastException invalidCast)
System.Xaml (2)
System\Windows\Markup\ArrayExtension.cs (1)
91catch (InvalidCastException)
System\Xaml\InfosetObjects\XamlObjectWriter.cs (1)
1893!(ex.InnerException is InvalidCastException))
UIAutomationClientSideProviders (2)
MS\Internal\AutomationProxies\Accessible.cs (2)
176catch (InvalidCastException) 1374else if (e is InvalidCastException)