182 instantiations of InvalidCastException
Aspire.Confluent.Kafka (1)
Aspire.Microsoft.Data.SqlClient (1)
Aspire.Microsoft.EntityFrameworkCore.SqlServer (1)
Aspire.StackExchange.Redis (1)
Crossgen2Tasks (1)
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));
Microsoft.AspNetCore.DataProtection (1)
Microsoft.AspNetCore.Mvc.Core.TestCommon (1)
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (2)
Microsoft.CodeAnalysis.EditorFeatures.Wpf (2)
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)
Microsoft.DotNet.Git.IssueManager (3)
Microsoft.DotNet.XUnitAssert.Tests (17)
Microsoft.Extensions.Http.Resilience.Tests (3)
Microsoft.Maui.Controls (2)
Microsoft.Maui.Controls.Compatibility (1)
Microsoft.VisualBasic.Core (6)
Microsoft.VisualStudio.LanguageServices.DevKit (2)
PresentationFramework (2)
System.Collections.Concurrent (1)
System.ComponentModel.Annotations (3)
System.Data.Common (2)
System.Data.Odbc (3)
System.Linq.Expressions (4)
System.Private.CoreLib (52)
src\libraries\System.Private.CoreLib\src\System\Char.cs (5)
519throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Boolean"));
569throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Single"));
574throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Double"));
579throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Decimal"));
584throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "DateTime"));
System.Private.Windows.Core (5)
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.Reflection.Metadata (1)
System.Runtime.InteropServices (1)
System.Text.Json (1)
System.Text.RegularExpressions (1)
System.Windows.Forms (10)
614 references to InvalidCastException
dotnet-svcutil-lib (38)
Microsoft.Analyzers.Local (3)
Microsoft.AspNetCore.Components.Tests (1)
Microsoft.AspNetCore.DataProtection (1)
Microsoft.AspNetCore.DataProtection.Tests (2)
Microsoft.AspNetCore.Http.Abstractions.Tests (4)
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (2)
Microsoft.AspNetCore.Mvc.Core.Test (1)
Microsoft.AspNetCore.Mvc.Core.TestCommon (3)
Microsoft.AspNetCore.Mvc.Razor.Test (1)
Microsoft.Build (9)
Microsoft.Build.Engine.OM.UnitTests (2)
Microsoft.Build.Framework (7)
Microsoft.Build.Tasks.Core (2)
Microsoft.Build.Utilities.Core (2)
Microsoft.CodeAnalysis (9)
Microsoft.CodeAnalysis.CodeStyle (7)
Microsoft.CodeAnalysis.Collections.Package (7)
Microsoft.CodeAnalysis.CSharp (2)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (3)
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.UnitTests (1)
Microsoft.CodeAnalysis.Workspaces (7)
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (7)
Microsoft.Data.Analysis.Tests (1)
Microsoft.DotNet.XUnitAssert.Tests (35)
Microsoft.DotNet.XUnitExtensions (1)
Microsoft.Extensions.AI.Abstractions (1)
Microsoft.Extensions.Diagnostics.Testing (1)
Microsoft.Maui (1)
Microsoft.Maui.Controls (3)
Microsoft.VisualBasic.Core (2)
MSBuild (2)
MSBuildTaskHost (2)
mscorlib (1)
netstandard (1)
PresentationCore (32)
PresentationCore.Tests (2)
PresentationFramework (18)
System.Collections (5)
System.Collections.Concurrent (1)
System.Collections.Immutable (1)
System.ComponentModel.Annotations (2)
System.ComponentModel.Composition (8)
System.ComponentModel.TypeConverter (4)
System.Data.Common (15)
System.Data.Odbc (11)
System.Linq.Expressions (6)
System.Private.CoreLib (13)
System.Private.Windows.Core (3)
System.Private.Windows.Core.Tests (11)
System.Private.Xml (39)
System.Resources.Extensions (2)
System.Runtime (1)
System.Text.Json (10)
System.Windows.Forms (5)
System.Windows.Forms.Design (1)
System.Windows.Forms.Design.Tests (2)
System.Windows.Forms.Primitives (1)
System.Windows.Forms.Primitives.TestUtilities (1)
System.Windows.Forms.Tests (31)
System.Xaml (2)
System.Xaml.Tests (44)
UIAutomationClientSideProviders (2)
WindowsBase.Tests (158)
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));
xunit.assert (1)