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)
96throw 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.Microsoft.Data.SqlClient (1)
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\Shared\Guard.cs (1)
177throw new InvalidCastException($"Cannot cast '{paramName}' from '{value?.GetType().ToString() ?? "null"}' to '{typeof(T)}'");
Aspire.Microsoft.EntityFrameworkCore.SqlServer (1)
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\Shared\Guard.cs (1)
177throw new InvalidCastException($"Cannot cast '{paramName}' from '{value?.GetType().ToString() ?? "null"}' to '{typeof(T)}'");
Aspire.StackExchange.Redis (1)
src\Vendoring\OpenTelemetry.Instrumentation.StackExchangeRedis\Shared\Guard.cs (1)
185throw new InvalidCastException($"Cannot cast '{paramName}' from '{value?.GetType().ToString() ?? "null"}' to '{typeof(T)}'");
Crossgen2Tasks (1)
CommonFilePulledFromSdkRepo\MessageLevel.cs (1)
27=> 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.DataProtection (1)
TypeExtensions.cs (1)
26throw new InvalidCastException(Resources.FormatTypeExtensions_BadCast(
Microsoft.AspNetCore.Mvc.Core.TestCommon (1)
CommonResourceInvokerTest.cs (1)
691var expected = new InvalidCastException();
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (2)
Rendering\HtmlHelperValidationSummaryTest.cs (2)
673modelState.AddModelError("Property3", new InvalidCastException("Exception will be ignored."), metadata); 692modelState.AddModelError("Property3", new InvalidCastException("An ignored Exception."), metadata);
Microsoft.CodeAnalysis.EditorFeatures (2)
Lightup\ISmartRenameSessionFactoryWrapper.cs (1)
43throw new InvalidCastException($"Cannot cast '{instance.GetType().FullName}' to '{WrappedTypeName}'");
Lightup\ISmartRenameSessionWrapper.cs (1)
115throw new InvalidCastException($"Cannot cast '{instance.GetType().FullName}' to '{WrappedTypeName}'");
Microsoft.CodeAnalysis.LanguageServer.Protocol (12)
Protocol\SumType.cs (12)
90public static explicit operator T1(SumType<T1, T2> sum) => sum.Value is T1 tVal ? tVal : throw new InvalidCastException(); 97public static explicit operator T2(SumType<T1, T2> sum) => sum.Value is T2 tVal ? tVal : throw new InvalidCastException(); 330throw new InvalidCastException(); 338public static explicit operator T1(SumType<T1, T2, T3> sum) => sum.Value is T1 tVal ? tVal : throw new InvalidCastException(); 345public static explicit operator T2(SumType<T1, T2, T3> sum) => sum.Value is T2 tVal ? tVal : throw new InvalidCastException(); 352public static explicit operator T3(SumType<T1, T2, T3> sum) => sum.Value is T3 tVal ? tVal : throw new InvalidCastException(); 652throw new InvalidCastException(); 676throw new InvalidCastException(); 684public static explicit operator T1(SumType<T1, T2, T3, T4> sum) => sum.Value is T1 tVal ? tVal : throw new InvalidCastException(); 691public static explicit operator T2(SumType<T1, T2, T3, T4> sum) => sum.Value is T2 tVal ? tVal : throw new InvalidCastException(); 698public static explicit operator T3(SumType<T1, T2, T3, T4> sum) => sum.Value is T3 tVal ? tVal : throw new InvalidCastException(); 705public static explicit operator T4(SumType<T1, T2, T3, T4> sum) => sum.Value is T4 tVal ? tVal : throw new InvalidCastException();
Microsoft.Data.Analysis (1)
DataFrame.cs (1)
390throw new InvalidCastException(String.Format(Strings.BadColumnCastDuringGrouping, columnName, column.DataType, typeof(TKey)));
Microsoft.DotNet.Git.IssueManager (2)
Helpers\RepositoryHelper.cs (2)
39throw new InvalidCastException($"'{parsedUri}' is not a valid URI"); 73throw new InvalidCastException($"'{parsedUri}' is not a valid URI");
Microsoft.DotNet.XUnitAssert.Tests (16)
ExceptionAssertsTests.cs (3)
693 throw new InvalidCastException(); 777 throw new InvalidCastException(); 915 throw new InvalidCastException();
TypeAssertsTests.cs (13)
18 var expected = new InvalidCastException(); 26 var expected = new InvalidCastException(); 42 var expected = new InvalidCastException(); 72 var expected = new InvalidCastException(); 80 var expected = new InvalidCastException(); 96 var expected = new InvalidCastException(); 120 var expected = new InvalidCastException(); 130 () => Assert.IsNotType<InvalidCastException>(new InvalidCastException())); 147 var expected = new InvalidCastException(); 157 () => Assert.IsNotType(typeof(InvalidCastException), new InvalidCastException())); 174 var expected = new InvalidCastException(); 182 var expected = new InvalidCastException(); 211 var expected = 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.Maui.Controls (1)
DependencyResolver.cs (1)
35 throw new InvalidCastException("Resolved instance is not of the correct type.");
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()
Microsoft.VisualStudio.LanguageServices.DevKit (2)
Logging\VSCodeTelemetryLogger.cs (2)
97throw new InvalidCastException($"Unexpected value for scope: {scope}"); 195_ => throw new InvalidCastException($"Unexpected value for scope: {scope}")
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)
309throw new InvalidCastException(e.Message, e);
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\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\libraries\Common\src\System\Data\Common\AdapterUtil.cs (1)
104InvalidCastException e = new InvalidCastException(error, 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 (53)
src\coreclr\nativeaot\Runtime.Base\src\System\Runtime\ExceptionHandling.cs (1)
325ExceptionIDs.InvalidCast => new InvalidCastException(),
src\libraries\System.Private.CoreLib\src\System\Array.cs (1)
558throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement);
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\libraries\System.Private.CoreLib\src\System\Byte.cs (1)
249throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Byte", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\Char.cs (5)
552throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Boolean")); 602throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Single")); 607throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Double")); 612throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Decimal")); 617throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\Convert.cs (8)
138throw new InvalidCastException(SR.InvalidCast_IConvertible); 162TypeCode.DBNull => throw new InvalidCastException(SR.InvalidCast_DBNull), 163TypeCode.Empty => throw new InvalidCastException(SR.InvalidCast_Empty), 215throw new InvalidCastException(SR.InvalidCast_DBNull); 217throw new InvalidCastException(SR.InvalidCast_Empty); 219throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, value.GetType().FullName, targetType.FullName)); 237throw new InvalidCastException(SR.InvalidCast_CannotCastNullToValueType); 248throw new InvalidCastException(SR.InvalidCast_IConvertible);
src\libraries\System.Private.CoreLib\src\System\DateTime.cs (1)
1973private static InvalidCastException InvalidCast(string to) => new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, nameof(DateTime), to));
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\libraries\System.Private.CoreLib\src\System\Decimal.cs (2)
1042throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Decimal", "Char")); 1102throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Decimal", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\Double.cs (2)
459throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Double", "Char")); 519throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Double", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\Enum.cs (1)
2190DateTime IConvertible.ToDateTime(IFormatProvider? provider) => throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Enum", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\Int16.cs (1)
252throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int16", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\Int32.cs (1)
267throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int32", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\Int64.cs (1)
264throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int64", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\ComWrappers.cs (1)
1517throw new InvalidCastException();
src\libraries\System.Private.CoreLib\src\System\SByte.cs (1)
255throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "SByte", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\Single.cs (2)
454throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Single", "Char")); 514throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Single", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\UInt16.cs (1)
246throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt16", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\UInt32.cs (1)
262throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt32", "DateTime"));
src\libraries\System.Private.CoreLib\src\System\UInt64.cs (1)
261throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt64", "DateTime"));
src\System\Array.CoreCLR.cs (2)
228throw new InvalidCastException(SR.InvalidCast_StoreArrayElement); 264throw new InvalidCastException(SR.InvalidCast_StoreArrayElement);
src\System\Runtime\InteropServices\DynamicInterfaceCastableHelpers.cs (2)
20throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, castable.GetType(), interfaceType)); 30throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, castable.GetType(), interfaceType));
src\System\TypedReference.CoreCLR.cs (1)
33static void ThrowInvalidCastException() => throw new InvalidCastException();
System.Private.Windows.Core (5)
System\Value.cs (1)
81throw new InvalidCastException($"{from?.Name ?? "<null>"} cannot be cast to {to.Name}");
Windows\Win32\Foundation\HandleRef.cs (2)
56throw new InvalidCastException(); 67throw new InvalidCastException();
Windows\Win32\System\Variant\VARIANT.cs (2)
958=> value.vt == VT_UNKNOWN ? value.data.punkVal : throw new InvalidCastException(); 973private 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)
1326return new InvalidCastException(SR.Format(SR.XmlInvalidNullCast, type.FullName)); 1328return new InvalidCastException(SR.Format(SR.XmlInvalidCast, value.GetType().FullName, type.FullName)); 1330return 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)
81throw 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));
677 references to InvalidCastException
Aspire.Hosting.Kubernetes (1)
Resources\Int32OrStringV1.cs (1)
68/// <exception cref="InvalidCastException">Thrown if the value isn't a valid integer.</exception>
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\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Metrics (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Metrics.Legacy (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.Analyzers.Local (3)
ApiLifecycle\Json\JsonValue.cs (3)
429/// <exception cref="System.InvalidCastException"> 451/// <exception cref="System.InvalidCastException"> 473/// <exception cref="System.InvalidCastException">
Microsoft.AspNetCore.Components.Tests (1)
ParameterViewTest.cs (1)
232Assert.Throws<InvalidCastException>(() =>
Microsoft.AspNetCore.DataProtection (1)
TypeExtensions.cs (1)
16/// Throws <see cref="InvalidCastException"/> if <paramref name="implementationType"/>
Microsoft.AspNetCore.DataProtection.Tests (2)
ActivatorTests.cs (2)
62var ex = Assert.Throws<InvalidCastException>(
Microsoft.AspNetCore.Http.Abstractions.Tests (4)
EndpointFilterInvocationContextOfTTests.cs (4)
24Assert.Throws<InvalidCastException>(() => context.GetArgument<string>(1)); 25Assert.Throws<InvalidCastException>(() => context.GetArgument<int>(0)); 26Assert.Throws<InvalidCastException>(() => context.GetArgument<string>(3)); 43Assert.Throws<InvalidCastException>(() => context[0] = 4);
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (2)
ApiResponseTypeProviderTest.cs (2)
586new ProducesResponseTypeAttribute(typeof(InvalidCastException), 400), 610Assert.Equal(typeof(InvalidCastException), responseType.Type);
Microsoft.AspNetCore.Mvc.Core.Test (1)
Infrastructure\ControllerActionInvokerTest.cs (1)
1346await Assert.ThrowsAsync<InvalidCastException>(
Microsoft.AspNetCore.Mvc.Core.TestCommon (3)
CommonResourceInvokerTest.cs (3)
691var expected = new InvalidCastException(); 724var thrown = await Assert.ThrowsAsync<InvalidCastException>(invoker.InvokeAsync);
Microsoft.AspNetCore.Mvc.Razor.Test (1)
RazorPageActivatorTest.cs (1)
166Assert.Throws<InvalidCastException>(() => activator.Activate(instance, viewContext));
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\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.Analyzers (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.AnalyzerUtilities (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.BannedApiAnalyzers (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.CodeStyle (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.Collections.Package (7)
Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
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.CSharp.Semantic.UnitTests (1)
Semantics\SyntaxTreeRootTests.cs (1)
108Assert.Throws<InvalidCastException>(() => { var _ = (CSharpSyntaxTree)(Object)tree.GetCompilationUnitRoot(); });
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (3)
Compilation\CompilationAPITests.cs (3)
1601Exception invalidCastSynTreeEx = Assert.Throws<InvalidCastException>( 1606invalidCastSynTreeEx = Assert.Throws<InvalidCastException>( 1611invalidCastSynTreeEx = Assert.Throws<InvalidCastException>(
Microsoft.CodeAnalysis.Extensions.Package (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.InteractiveHost (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.LanguageServer.Protocol (9)
Protocol\SumType.cs (9)
88/// <exception cref="InvalidCastException">Thrown if this instance of <see cref="SumType{T1, T2}"/> does not contain an instance of <typeparamref name="T1"/>.</exception> 95/// <exception cref="InvalidCastException">Thrown if this instance of <see cref="SumType{T1, T2}"/> does not contain an instance of <typeparamref name="T2"/>.</exception> 336/// <exception cref="InvalidCastException">Thrown if this instance of <see cref="SumType{T1, T2, T3}"/> does not contain an instance of <typeparamref name="T1"/>.</exception> 343/// <exception cref="InvalidCastException">Thrown if this instance of <see cref="SumType{T1, T2, T3}"/> does not contain an instance of <typeparamref name="T2"/>.</exception> 350/// <exception cref="InvalidCastException">Thrown if this instance of <see cref="SumType{T1, T2, T3}"/> does not contain an instance of <typeparamref name="T3"/>.</exception> 682/// <exception cref="InvalidCastException">Thrown if this instance of <see cref="SumType{T1, T2, T3, T4}"/> does not contain an instance of <typeparamref name="T1"/>.</exception> 689/// <exception cref="InvalidCastException">Thrown if this instance of <see cref="SumType{T1, T2, T3, T4}"/> does not contain an instance of <typeparamref name="T2"/>.</exception> 696/// <exception cref="InvalidCastException">Thrown if this instance of <see cref="SumType{T1, T2, T3, T4}"/> does not contain an instance of <typeparamref name="T3"/>.</exception> 703/// <exception cref="InvalidCastException">Thrown if this instance of <see cref="SumType{T1, T2, T3, T4}"/> does not contain an instance of <typeparamref name="T4"/>.</exception>
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.PublicApiAnalyzers (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.ResxSourceGenerator (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.Threading.Package (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.UnitTests (1)
Collections\List\ICollection.NonGeneric.Tests.cs (1)
58protected virtual Type ICollection_NonGeneric_CopyTo_ArrayOfEnumType_ThrowType => typeof(InvalidCastException);
Microsoft.CodeAnalysis.Workspaces (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
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.DotNet.XUnitAssert.Tests (31)
ExceptionAssertsTests.cs (4)
59 Assert.Throws<InvalidCastException>(() => ThrowingMethod()); 132 Assert.Throws<InvalidCastException>(() => accessor.FailingProperty); 286 Assert.ThrowsAny<InvalidCastException>(() => ThrowingMethod()); 354 Assert.ThrowsAny<InvalidCastException>(() => accessor.FailingProperty);
TypeAssertsTests.cs (27)
18 var expected = new InvalidCastException(); 20 Assert.IsAssignableFrom<InvalidCastException>(expected); 26 var expected = new InvalidCastException(); 42 var expected = new InvalidCastException(); 44 var actual = Assert.IsAssignableFrom<InvalidCastException>(expected); 54 () => Assert.IsAssignableFrom<InvalidCastException>(new InvalidOperationException()) 72 var expected = new InvalidCastException(); 74 Assert.IsAssignableFrom(typeof(InvalidCastException), expected); 80 var expected = new InvalidCastException(); 96 var expected = new InvalidCastException(); 98 var actual = Assert.IsAssignableFrom<InvalidCastException>(expected); 108 () => Assert.IsAssignableFrom(typeof(InvalidCastException), new InvalidOperationException()) 120 var expected = new InvalidCastException(); 130 () => Assert.IsNotType<InvalidCastException>(new InvalidCastException())); 147 var expected = new InvalidCastException(); 157 () => Assert.IsNotType(typeof(InvalidCastException), new InvalidCastException())); 174 var expected = new InvalidCastException(); 176 Assert.IsType<InvalidCastException>(expected); 182 var expected = new InvalidCastException(); 184 var actual = Assert.IsType<InvalidCastException>(expected); 194 () => Assert.IsType<InvalidCastException>(new InvalidOperationException())); 211 var expected = new InvalidCastException(); 213 Assert.IsType(typeof(InvalidCastException), expected); 221 () => Assert.IsType(typeof(InvalidCastException), new InvalidOperationException()));
Microsoft.Extensions.AI.Abstractions (1)
AdditionalPropertiesDictionary{TValue}.cs (1)
180catch (Exception e) when (e is ArgumentException or FormatException or InvalidCastException or OverflowException)
Microsoft.Extensions.Diagnostics.Testing (1)
Logging\FakeLogRecord.cs (1)
67/// <exception cref="InvalidCastException">The state object is not compatible with supported logging model and is not a read-only list.</exception>
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.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())
mscorlib (1)
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)
PresentationCore.Tests (2)
System\Windows\Input\MouseActionConverter.Tests.cs (2)
66Assert.Throws<InvalidCastException>(() => converter.CanConvertTo(context, typeof(string))); 175Assert.Throws<InvalidCastException>(() => converter.ConvertTo(null, null, (int)(MouseAction.MiddleDoubleClick), typeof(string)));
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)
2036catch (InvalidCastException)
PresentationFramework.Tests (1)
System\Windows\Controls\VirtualizationCacheLengthConverter.Tests.cs (1)
169Assert.Throws<InvalidCastException>(() => converter.ConvertFrom(null, culture, value));
Roslyn.Diagnostics.Analyzers (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
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)
1584catch (InvalidCastException)
System.Collections.Immutable (1)
System\Collections\Immutable\ImmutableArray_1.Minimal.cs (1)
348/// <exception cref="InvalidCastException">Thrown if the cast is illegal.</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\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\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.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.Private.CoreLib (13)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\Dictionary.cs (4)
1674catch (InvalidCastException) 1679catch (InvalidCastException) 1711catch (InvalidCastException) 1716catch (InvalidCastException)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\List.cs (3)
184catch (InvalidCastException) 231catch (InvalidCastException) 798catch (InvalidCastException)
src\libraries\System.Private.CoreLib\src\System\Collections\ObjectModel\Collection.cs (3)
254catch (InvalidCastException) 295catch (InvalidCastException) 337catch (InvalidCastException)
src\libraries\System.Private.CoreLib\src\System\DateTime.cs (1)
1973private static InvalidCastException InvalidCast(string to) => new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, nameof(DateTime), to));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\IDynamicInterfaceCastable.cs (1)
29/// true and this function returns false, then <see cref="InvalidCastException" />
src\libraries\System.Private.CoreLib\src\System\RuntimeType.cs (1)
513catch (InvalidCastException)
System.Private.Windows.Core (3)
System\Private\Windows\Nrbf\SerializationRecordExtensions.cs (2)
31catch (Exception ex) when (ex is ArgumentException or InvalidCastException or ArithmeticException or IOException or TargetInvocationException) 71catch (Exception ex) when (ex is KeyNotFoundException or InvalidCastException)
System\Value.cs (1)
1038/// <exception cref="InvalidCastException">
System.Private.Windows.Core.Tests (12)
System\Private\Windows\Ole\BinaryFormatUtilitiesTests.cs (1)
633action.Should().Throw<InvalidCastException>();
System\Value\StoringArrays.cs (8)
19Assert.Throws<InvalidCastException>(() => value.GetValue<ArraySegment<byte>>()); 33Assert.Throws<InvalidCastException>(() => value.GetValue<ArraySegment<char>>()); 47Assert.Throws<InvalidCastException>(() => value.GetValue<byte[]>()); 54Assert.Throws<InvalidCastException>(() => value.GetValue<byte[]>()); 61Assert.Throws<InvalidCastException>(() => value.GetValue<byte[]>()); 75Assert.Throws<InvalidCastException>(() => value.GetValue<char[]>()); 82Assert.Throws<InvalidCastException>(() => value.GetValue<char[]>()); 89Assert.Throws<InvalidCastException>(() => value.GetValue<char[]>());
System\Value\StoringNull.cs (2)
12Assert.Throws<InvalidCastException>(() => _ = nullValue.GetValue<int>()); 15Assert.Throws<InvalidCastException>(() => _ = nullFastValue.GetValue<int>());
System\Value\StoringObject.cs (1)
34Assert.Throws<InvalidCastException>(() => value.GetValue<C>());
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)
67catch (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)
1545catch (InvalidCastException) 5101WriteCatchException(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)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
285[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.Text.Json (10)
System\Text\Json\Serialization\JsonSerializer.Read.HandleMetadata.cs (1)
529catch (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)
81/// <exception cref="InvalidCastException">
System\Text\Json\Serialization\JsonSerializer.Write.Stream.cs (2)
205/// <exception cref="InvalidCastException"> 230/// <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.Design.Tests (2)
System\ComponentModel\Design\DesignerCommandSetTests.cs (2)
46Assert.Throws<InvalidCastException>(() => mockSet.Object.Verbs); 67Assert.Throws<InvalidCastException>(() => mockSet.Object.ActionLists);
System.Windows.Forms.Primitives (1)
System\Windows\Forms\PaddingConverter.cs (1)
99catch (InvalidCastException invalidCast)
System.Windows.Forms.Primitives.TestUtilities (1)
PlatformDetection.Windows.cs (1)
183catch (Exception e) when (e is SecurityException or InvalidCastException or PlatformNotSupportedException /* UAP */)
System.Windows.Forms.Tests (31)
System\Windows\Forms\AxHost.ConnectionPointCookieTests.cs (4)
39Assert.Throws<InvalidCastException>(() => new AxHost.ConnectionPointCookie(source, null, null)); 40Assert.Throws<InvalidCastException>(() => new AxHost.ConnectionPointCookie(source, new object(), typeof(int))); 60Assert.Throws<InvalidCastException>(() => new AxHost.ConnectionPointCookie(source, null, eventInterface)); 76Assert.Throws<InvalidCastException>(() => new AxHost.ConnectionPointCookie(source, sink, eventInterface));
System\Windows\Forms\AxHostTests.cs (3)
1442Assert.Throws<InvalidCastException>(() => SubAxHost.GetFontFromIFont(new object())); 1603Assert.Throws<InvalidCastException>(() => SubAxHost.GetPictureFromIPicture(iPicture)); 1737Assert.Throws<InvalidCastException>(() => SubAxHost.GetPictureFromIPicture(new object()));
System\Windows\Forms\DataGridViewButtonColumnTests.cs (1)
161action.Should().Throw<InvalidCastException>();
System\Windows\Forms\DataGridViewLinkColumnTests.cs (1)
83action.Should().Throw<InvalidCastException>()
System\Windows\Forms\DataGridViewTextBoxColumnTests.cs (1)
48action.Should().Throw<InvalidCastException>()
System\Windows\Forms\DataGridViewTextBoxEditingControlTests.cs (1)
287Assert.Throws<InvalidCastException>(() => control.EditingControlFormattedValue = new object());
System\Windows\Forms\HtmlDocumentTests.cs (1)
1649Assert.Throws<InvalidCastException>(() => document.Equals(new object()));
System\Windows\Forms\Layout\TableLayoutSettingsTypeConverterTests.cs (3)
262Assert.Throws<InvalidCastException>(() => settings.ColumnStyles.Add(new RowStyle())); 265Assert.Throws<InvalidCastException>(() => converter.ConvertTo(settings, typeof(string))); 276Assert.Throws<InvalidCastException>(() => converter.ConvertTo(settings, typeof(string)));
System\Windows\Forms\PropertyGridTests.cs (1)
2397Assert.Throws<InvalidCastException>(() => control.SelectedGridItem = mockGridItem.Object);
System\Windows\Forms\PropertyStoreTests.cs (5)
104action.Should().Throw<InvalidCastException>(); 114action.Should().Throw<InvalidCastException>(); 124action.Should().Throw<InvalidCastException>(); 222action.Should().Throw<InvalidCastException>(); 228action.Should().Throw<InvalidCastException>();
System\Windows\Forms\TabControl.TabPageCollectionTests.cs (2)
1294Assert.Throws<InvalidCastException>(() => iList.CopyTo(array, 1)); 1845Assert.Throws<InvalidCastException>(collection.GetEnumerator);
System\Windows\Forms\TabControlTests.cs (2)
3905Assert.Throws<InvalidCastException>(() => control.GetItems(baseType)); 3916Assert.Throws<InvalidCastException>(() => control.GetItems(typeof(int)));
System\Windows\Forms\TableLayoutColumnStyleCollectionTests.cs (3)
30Assert.Throws<InvalidCastException>(() => collection.Add(style)); 66Assert.Throws<InvalidCastException>(() => collection.Add(new RowStyle())); 67Assert.Throws<InvalidCastException>(() => collection[0]);
System\Windows\Forms\TableLayoutRowStyleCollectionTests.cs (1)
67Assert.Throws<InvalidCastException>(() => collection[0]);
System\Windows\Forms\TableLayoutStyleCollectionTests.cs (1)
65Assert.Throws<InvalidCastException>(() => collection.Add(new object()));
System\Windows\Forms\WebBrowserTests.cs (1)
2378Assert.Throws<InvalidCastException>(() => control.AttachInterfaces(new object()));
System.Xaml (2)
System\Windows\Markup\ArrayExtension.cs (1)
91catch (InvalidCastException)
System\Xaml\InfosetObjects\XamlObjectWriter.cs (1)
1893!(ex.InnerException is InvalidCastException))
System.Xaml.Tests (44)
System\Windows\Markup\NameReferenceConverterTests.cs (2)
100Assert.Throws<InvalidCastException>(() => converter.ConvertFrom(context, null, "name")); 192Assert.Throws<InvalidCastException>(() => converter.ConvertTo(context, null, "value", null));
System\Windows\Markup\StringValueSerializerTests.cs (1)
37Assert.Throws<InvalidCastException>(() => serializer.ConvertToString(1, null));
System\Windows\Markup\ValueSerializerTests.cs (4)
235Assert.Throws<InvalidCastException>(() => ValueSerializer.GetSerializerFor(typeof(ClassWithInvalidValueSerializerAttribute))); 236Assert.Throws<InvalidCastException>(() => ValueSerializer.GetSerializerFor(typeof(ClassWithInvalidValueSerializerAttribute), null)); 301Assert.Throws<InvalidCastException>(() => ValueSerializer.GetSerializerFor(descriptor)); 302Assert.Throws<InvalidCastException>(() => ValueSerializer.GetSerializerFor(descriptor, null));
System\Xaml\Schema\XamlValueConverterTests.cs (1)
95Assert.Throws<InvalidCastException>(() => converter.ConverterInstance);
System\Xaml\XamlBackgroundReaderTests.cs (1)
55Assert.Throws<InvalidCastException>(() => new XamlBackgroundReader(new SubXamlReader()));
System\Xaml\XamlMemberTests.cs (11)
513Assert.Throws<InvalidCastException>(() => member.LookupDeferringLoaderEntry()); 514Assert.Throws<InvalidCastException>(() => member.DeferringLoader); 673Assert.Throws<InvalidCastException>(() => member.LookupDependsOnEntry()); 674Assert.Throws<InvalidCastException>(() => member.DependsOn); 1391Assert.Throws<InvalidCastException>(() => member.LookupMarkupExtensionBracketCharactersEntry()); 1392Assert.Throws<InvalidCastException>(() => member.MarkupExtensionBracketCharacters); 1513Assert.Throws<InvalidCastException>(() => member.SerializationVisibility); 1805Assert.Throws<InvalidCastException>(() => member.LookupTypeConverterEntry()); 1806Assert.Throws<InvalidCastException>(() => member.TypeConverter); 2156Assert.Throws<InvalidCastException>(() => member.LookupValueSerializerEntry()); 2157Assert.Throws<InvalidCastException>(() => member.ValueSerializer);
System\Xaml\XamlSchemaContextTests.cs (2)
358Assert.Throws<InvalidCastException>(() => context.GetPreferredPrefix("xmlns")); 386Assert.Throws<InvalidCastException>(() => context.GetPreferredPrefix("xmlns"));
System\Xaml\XamlTypeTests.cs (22)
390Assert.Throws<InvalidCastException>(() => type.GetXamlNamespaces()); 422Assert.Throws<InvalidCastException>(() => type.GetXamlNamespaces()); 675Assert.Throws<InvalidCastException>(() => type.LookupAliasedPropertyEntry(directive)); 676Assert.Throws<InvalidCastException>(() => type.GetAliasedProperty(directive)); 1479Assert.Throws<InvalidCastException>(() => type.LookupAllowedContentTypesEntry()); 1480Assert.Throws<InvalidCastException>(() => type.AllowedContentTypes); 2083Assert.Throws<InvalidCastException>(() => type.LookupContentPropertyEntry()); 2084Assert.Throws<InvalidCastException>(() => type.ContentProperty); 2267Assert.Throws<InvalidCastException>(() => type.LookupContentWrappersEntry()); 2268Assert.Throws<InvalidCastException>(() => type.ContentWrappers); 2446Assert.Throws<InvalidCastException>(() => type.LookupDeferringLoaderEntry()); 2447Assert.Throws<InvalidCastException>(() => type.DeferringLoader); 3417Assert.Throws<InvalidCastException>(() => type.LookupMarkupExtensionReturnTypeEntry()); 3418Assert.Throws<InvalidCastException>(() => type.MarkupExtensionReturnType); 3848Assert.Throws<InvalidCastException>(() => type.LookupSetMarkupExtensionHandlerEntry()); 4047Assert.Throws<InvalidCastException>(() => type.LookupSetTypeConverterHandlerEntry()); 4345Assert.Throws<InvalidCastException>(() => type.LookupTypeConverterEntry()); 4346Assert.Throws<InvalidCastException>(() => type.TypeConverter); 4575Assert.Throws<InvalidCastException>(() => type.LookupUsableDuringInitializationEntry()); 4576Assert.Throws<InvalidCastException>(() => type.IsUsableDuringInitialization); 4753Assert.Throws<InvalidCastException>(() => type.LookupValueSerializerEntry()); 4754Assert.Throws<InvalidCastException>(() => type.ValueSerializer);
Test.Utilities (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
Text.Analyzers (7)
src\Dependencies\Collections\Segmented\SegmentedDictionary`2.cs (4)
1083catch (InvalidCastException) 1088catch (InvalidCastException) 1120catch (InvalidCastException) 1125catch (InvalidCastException)
src\Dependencies\Collections\Segmented\SegmentedList`1.cs (3)
238catch (InvalidCastException) 285catch (InvalidCastException) 881catch (InvalidCastException)
UIAutomationClientSideProviders (2)
MS\Internal\AutomationProxies\Accessible.cs (2)
176catch (InvalidCastException) 1374else if (e is InvalidCastException)
WindowsBase.Tests (158)
System\Windows\DependencyPropertyChangedEventArgsTests.cs (1)
86Assert.Throws<InvalidCastException>(() => args.Equals(new object()));
System\Windows\Input\KeyConverterTests.cs (4)
81Assert.Throws<InvalidCastException>(() => converter.CanConvertTo(context, typeof(string))); 179Assert.Throws<InvalidCastException>(() => converter.ConvertTo(value, typeof(string))); 180Assert.Throws<InvalidCastException>(() => converter.ConvertTo(new CustomTypeDescriptorContext(), null, value, typeof(string))); 181Assert.Throws<InvalidCastException>(() => converter.ConvertTo(new CustomTypeDescriptorContext(), CultureInfo.InvariantCulture, value, typeof(string)));
System\Windows\Input\KeyValueSerializerTests.cs (2)
78Assert.Throws<InvalidCastException>(() => serializer.ConvertToString(value, null)); 79Assert.Throws<InvalidCastException>(() => serializer.ConvertToString(value, new CustomValueSerializerContext()));
System\Windows\Input\ModifierKeysConverterTests.cs (3)
145Assert.Throws<InvalidCastException>(() => converter.ConvertTo(value, typeof(string))); 146Assert.Throws<InvalidCastException>(() => converter.ConvertTo(new CustomTypeDescriptorContext(), null, value, typeof(string))); 147Assert.Throws<InvalidCastException>(() => converter.ConvertTo(new CustomTypeDescriptorContext(), CultureInfo.InvariantCulture, value, typeof(string)));
System\Windows\Input\ModifierKeysValueSerializerTests.cs (2)
74Assert.Throws<InvalidCastException>(() => serializer.ConvertToString(value, null)); 75Assert.Throws<InvalidCastException>(() => serializer.ConvertToString(value, new CustomValueSerializerContext()));
System\Windows\LocalValueEntryTests.cs (1)
89Assert.Throws<InvalidCastException>(() => entry.Equals(new object()));
System\Windows\WeakEventManagerTests.cs (145)
337Assert.Throws<InvalidCastException>(() => manager.DeliverEvent(source, args)); 352Assert.Throws<InvalidCastException>(() => manager.DeliverEvent(source, args)); 368Assert.Throws<InvalidCastException>(() => manager.DeliverEvent(source, args)); 425Assert.Throws<InvalidCastException>(() => manager.DeliverEvent(source, args)); 612Assert.Throws<InvalidCastException>(() => manager.DeliverEventToList(sender, args, list)); 625Assert.Throws<InvalidCastException>(() => manager.DeliverEventToList(sender, args, list)); 639Assert.Throws<InvalidCastException>(() => manager.DeliverEventToList(sender, args, list)); 801Assert.Throws<InvalidCastException>(() => list[1]); 812Assert.Throws<InvalidCastException>(() => list[1]); 816Assert.Throws<InvalidCastException>(() => list[0]); 826Assert.Throws<InvalidCastException>(() => list[1]); 830Assert.Throws<InvalidCastException>(() => list[0]); 964Assert.Throws<InvalidCastException>(() => list[0]); 973Assert.Throws<InvalidCastException>(() => list[0]); 974Assert.Throws<InvalidCastException>(() => list[1]); 1237Assert.Throws<InvalidCastException>(() => manager.ProtectedAddHandler(source, handler)); 1375Assert.Throws<InvalidCastException>(() => list[0]); 1383Assert.Throws<InvalidCastException>(() => list[0]); 1602Assert.Throws<InvalidCastException>(() => manager.ProtectedAddListener(source, listener)); 1640Assert.Throws<InvalidCastException>(() => list[0]); 1641Assert.Throws<InvalidCastException>(() => list[1]); 1653Assert.Throws<InvalidCastException>(() => list[0]); 1654Assert.Throws<InvalidCastException>(() => list[1]); 1664Assert.Throws<InvalidCastException>(() => list[0]); 1665Assert.Throws<InvalidCastException>(() => list[1]); 1675Assert.Throws<InvalidCastException>(() => list[0]); 1715Assert.Throws<InvalidCastException>(() => list[0]); 2141Assert.Throws<InvalidCastException>(() => manager.ProtectedRemoveHandler(source, handler)); 2280Assert.Throws<InvalidCastException>(() => list[0]); 2565Assert.Throws<InvalidCastException>(() => manager.ProtectedRemoveListener(source, listener)); 2684Assert.Throws<InvalidCastException>(() => manager.Purge(source, new object(), false)); 2823Assert.Throws<InvalidCastException>(() => manager.Purge(source, new object(), false)); 2986Assert.Throws<InvalidCastException>(() => list[1]); 2990Assert.Throws<InvalidCastException>(() => list[0]); 2998Assert.Throws<InvalidCastException>(() => list[1]); 3002Assert.Throws<InvalidCastException>(() => list[0]); 3035Assert.Throws<InvalidCastException>(() => list[3]); 3040Assert.Throws<InvalidCastException>(() => list[1]); 3050Assert.Throws<InvalidCastException>(() => list[3]); 3055Assert.Throws<InvalidCastException>(() => list[1]); 3339Assert.Throws<InvalidCastException>(() => list[0]); 3351Assert.Throws<InvalidCastException>(() => list[0]); 3460Assert.Throws<InvalidCastException>(() => list[2]); 3468Assert.Throws<InvalidCastException>(() => list[2]); 3477Assert.Throws<InvalidCastException>(() => list[2]); 3487Assert.Throws<InvalidCastException>(() => list[2]); 3498Assert.Throws<InvalidCastException>(() => list[2]); 3510Assert.Throws<InvalidCastException>(() => list[2]); 3617Assert.Throws<InvalidCastException>(() => list[2]); 3625Assert.Throws<InvalidCastException>(() => list[2]); 3626Assert.Throws<InvalidCastException>(() => list[3]); 3634Assert.Throws<InvalidCastException>(() => list[2]); 3635Assert.Throws<InvalidCastException>(() => list[3]); 3636Assert.Throws<InvalidCastException>(() => list[4]); 3644Assert.Throws<InvalidCastException>(() => list[2]); 3645Assert.Throws<InvalidCastException>(() => list[3]); 3646Assert.Throws<InvalidCastException>(() => list[4]); 3647Assert.Throws<InvalidCastException>(() => list[5]); 3655Assert.Throws<InvalidCastException>(() => list[2]); 3656Assert.Throws<InvalidCastException>(() => list[3]); 3657Assert.Throws<InvalidCastException>(() => list[4]); 3658Assert.Throws<InvalidCastException>(() => list[5]); 3667Assert.Throws<InvalidCastException>(() => list[2]); 3668Assert.Throws<InvalidCastException>(() => list[3]); 3669Assert.Throws<InvalidCastException>(() => list[4]); 3670Assert.Throws<InvalidCastException>(() => list[5]); 3793Assert.Throws<InvalidCastException>(() => list[0]); 3799Assert.Throws<InvalidCastException>(() => list[0]); 3800Assert.Throws<InvalidCastException>(() => list[1]); 3806Assert.Throws<InvalidCastException>(() => list[0]); 3807Assert.Throws<InvalidCastException>(() => list[1]); 3808Assert.Throws<InvalidCastException>(() => list[2]); 3821Assert.Throws<InvalidCastException>(() => list[0]); 3827Assert.Throws<InvalidCastException>(() => list[0]); 3828Assert.Throws<InvalidCastException>(() => list[1]); 3834Assert.Throws<InvalidCastException>(() => list[0]); 3835Assert.Throws<InvalidCastException>(() => list[1]); 3836Assert.Throws<InvalidCastException>(() => list[2]); 3874Assert.Throws<InvalidCastException>(() => list[0]); 3983Assert.Throws<InvalidCastException>(() => list[2]); 3984Assert.Throws<InvalidCastException>(() => list[3]); 3989Assert.Throws<InvalidCastException>(() => newList[2]); 3990Assert.Throws<InvalidCastException>(() => newList[3]); 4021Assert.Throws<InvalidCastException>(() => list[4]); 4022Assert.Throws<InvalidCastException>(() => list[5]); 4029Assert.Throws<InvalidCastException>(() => newList[4]); 4030Assert.Throws<InvalidCastException>(() => newList[5]); 4090Assert.Throws<InvalidCastException>(() => newList[2]); 4091Assert.Throws<InvalidCastException>(() => newList[3]); 4124Assert.Throws<InvalidCastException>(() => newList[4]); 4125Assert.Throws<InvalidCastException>(() => newList[5]); 4171Assert.Throws<InvalidCastException>(() => list[2]); 4172Assert.Throws<InvalidCastException>(() => list[3]); 4177Assert.Throws<InvalidCastException>(() => newList[2]); 4178Assert.Throws<InvalidCastException>(() => newList[3]); 4209Assert.Throws<InvalidCastException>(() => list[4]); 4210Assert.Throws<InvalidCastException>(() => list[5]); 4217Assert.Throws<InvalidCastException>(() => newList[4]); 4218Assert.Throws<InvalidCastException>(() => newList[5]); 4473Assert.Throws<InvalidCastException>(() => list.DeliverEvent(sender, args, managerType)); 4484Assert.Throws<InvalidCastException>(() => list.DeliverEvent(sender, args, managerType)); 4496Assert.Throws<InvalidCastException>(() => list.DeliverEvent(sender, args, managerType)); 4606Assert.Throws<InvalidCastException>(() => list[1]); 4607Assert.Throws<InvalidCastException>(() => list[2]); 4632Assert.Throws<InvalidCastException>(() => list[3]); 4633Assert.Throws<InvalidCastException>(() => list[4]); 4703Assert.Throws<InvalidCastException>(() => list[0]); 4709Assert.Throws<InvalidCastException>(() => list[0]); 4715Assert.Throws<InvalidCastException>(() => list[0]); 4780Assert.Throws<InvalidCastException>(() => list[1]); 4788Assert.Throws<InvalidCastException>(() => list[1]); 4794Assert.Throws<InvalidCastException>(() => list[0]); 4800Assert.Throws<InvalidCastException>(() => list[0]); 4806Assert.Throws<InvalidCastException>(() => list[0]); 4884Assert.Throws<InvalidCastException>(() => list[1]); 4892Assert.Throws<InvalidCastException>(() => list[1]); 4899Assert.Throws<InvalidCastException>(() => list[0]); 4906Assert.Throws<InvalidCastException>(() => list[0]); 4913Assert.Throws<InvalidCastException>(() => list[0]); 4919Assert.Throws<InvalidCastException>(() => list[0]); 5015Assert.Throws<InvalidCastException>(() => list[1]); 5026Assert.Throws<InvalidCastException>(() => list[1]); 5036Assert.Throws<InvalidCastException>(() => list[1]); 5044Assert.Throws<InvalidCastException>(() => list[0]); 5052Assert.Throws<InvalidCastException>(() => list[0]); 5061Assert.Throws<InvalidCastException>(() => list[0]); 5067Assert.Throws<InvalidCastException>(() => list[0]); 5172Assert.Throws<InvalidCastException>(() => list[1]); 5184Assert.Throws<InvalidCastException>(() => list[1]); 5195Assert.Throws<InvalidCastException>(() => list[1]); 5204Assert.Throws<InvalidCastException>(() => list[0]); 5213Assert.Throws<InvalidCastException>(() => list[0]); 5224Assert.Throws<InvalidCastException>(() => list[0]); 5230Assert.Throws<InvalidCastException>(() => list[0]); 5745Assert.Throws<InvalidCastException>(() => list[2]); 5746Assert.Throws<InvalidCastException>(() => list[3]); 5751Assert.Throws<InvalidCastException>(() => newList[2]); 5752Assert.Throws<InvalidCastException>(() => newList[3]); 5783Assert.Throws<InvalidCastException>(() => list[4]); 5784Assert.Throws<InvalidCastException>(() => list[5]); 5791Assert.Throws<InvalidCastException>(() => newList[4]); 5792Assert.Throws<InvalidCastException>(() => newList[5]); 5991Assert.Throws<InvalidCastException>(() => list.DeliverEvent(sender, args, managerType)); 6002Assert.Throws<InvalidCastException>(() => list.DeliverEvent(sender, args, managerType)); 6014Assert.Throws<InvalidCastException>(() => list.DeliverEvent(sender, args, managerType));