首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏全栈程序员必看

    System.ArgumentException: 回发或回调参数无效。在配置中使用 < pages enableEventValidation=”true”>

    异常详细信息: System.ArgumentException: 回发或回调参数无效。

    2.1K10编辑于 2022-09-15
  • 来自专栏技术之路

    【数据结构】二次封装自己的数组(一)完成数组基本功能

    void add(int index, int e) { if (size == data.Length) throw new ArgumentException ("Add failed.Array is full"); if (index < 0 || index > size) throw new ArgumentException int get(int index) { if (index < 0 || index >= size) throw new ArgumentException set(int index, int e) { if (index < 0 || index >= size) throw new ArgumentException int remove(int index) { if (index < 0 || index >= size) throw new ArgumentException

    18710编辑于 2024-04-23
  • 来自专栏科控自动化

    [C#] 分享一个上位机开发常用的string类

    { if(string.IsNullOrWhiteSpace(aType)) { throw new ArgumentException { if (string.IsNullOrWhiteSpace(aType)) { throw new ArgumentException = '{') throw new ArgumentException("Wrong format. "); if (aString.EndsWith("}") == false ) throw new ArgumentException("Wrong format. "); int lLength = (int)StringToObject = lLength) throw new ArgumentException("Wrong length. "); lArray = Array.CreateInstance

    63711编辑于 2022-03-29
  • 来自专栏C#

    DotNet处理服务器路径的方法

    public void ValidatePath(string path) { if (path == null) throw new ArgumentException ("路径不能为空"); if (path.Length == 0) throw new ArgumentException("路径长度必须大于0" = '/') throw new ArgumentException("路径必须启动/字符"); if (path.Length == 1) return ; if (path[path.Length - 1] == '/') throw new ArgumentException("路径不能结束与/ = null) throw new ArgumentException(string.Format("无效的路径字符串 \"{0}\" 引起的 {1}", path, reason));

    1.1K60发布于 2018-01-04
  • 来自专栏DotNet NB && CloudNative

    解锁数据完整性新境界:C#中"Parse, Don't Validate"模式深度实践指南

    Regex.IsMatch(zipCode, @"^\d{5}$")) { thrownew ArgumentException("Invalid zip code format Regex.IsMatch(code, @"^\d{5}$")) thrownew ArgumentException("ZipCode must be a 5-digit number IsValidEmail(value)) thrownew ArgumentException("Invalid email format", nameof(value)); $")) thrownew ArgumentException("Invalid US ZIP code format"); returnnew result = _orderService.CreateOrder(order); return Ok(result); } catch (ArgumentException

    19500编辑于 2025-06-11
  • 来自专栏菩提树下的杨过

    c#4.0中的不变(invariant)、协变(covariant)、逆变(contravariant)小记

    class Program { public static void Main(string[] args) { Func<object, ArgumentException > fn1 = Test; ArgumentException e1 = fn1("aaaaa"); Func<string, Exception> fn2 {0}\te2:{1}", e1.Message, e2.Message); Console.Read(); } public static ArgumentException Test(object obj) { return new ArgumentException(obj.ToString()); } >' to 'System.Func<string,System.Exception>'  即:无法隐式将System.Func<object,System.ArgumentException>转换成System.Func

    1.1K100发布于 2018-01-22
  • 来自专栏技术之路

    【数据结构】二次封装自己的数组(二)升级为泛型数组

    public void add(int index, E e) { if (size == data.Length) throw new ArgumentException ("Add failed.Array is full"); if (index < 0 || index > size) throw new ArgumentException E get(int index) { if (index < 0 || index >= size) throw new ArgumentException set(int index, E e) { if (index < 0 || index >= size) throw new ArgumentException E remove(int index) { if (index < 0 || index >= size) throw new ArgumentException

    23900编辑于 2024-04-23
  • 来自专栏林德熙的博客

    dotnet C# 在 finally 抛异常会发生什么

    } private void A() { try { throw new ArgumentException 试试上面的代码,可以看到其实在进入 try 时,抛出 ArgumentException 不会立刻返回到 F1 方法里面,而是会继续执行 finally 方法 在 finally 抛出的 FileNotFoundException 将会替换掉 ArgumentException 抛给了 F1 方法里面 所以答案就是在 F1 的 catch 方法,只会被触发一次,这一次的 e 就是在 finally 抛出的 FileNotFoundException

    46920编辑于 2021-12-24
  • 来自专栏Dotnet Dancer

    开始开源项目OpenTools的创作

    string key, string password, string iv) { if (key == null || key.Length < 32) throw new ArgumentException ", nameof(key)); if (iv == null || iv.Length < 16) throw new ArgumentException("IV must key, string encryptedText, string iv) { if (key == null || key.Length < 32) throw new ArgumentException ", nameof(key)); if (iv == null || iv.Length < 16) throw new ArgumentException("IV must

    26610编辑于 2024-08-13
  • 来自专栏跨界架构师

    如何一步一步用DDD设计一个电商网站(五)—— 停下脚步,重新出发

    [TestClass] public class CartTest { [TestMethod] [ExpectedException(typeof(ArgumentException Assert.AreNotEqual(null, cart); } [TestMethod] [ExpectedException(typeof(ArgumentException TestClass] public class CartItemTest { [TestMethod] [ExpectedException(typeof(ArgumentException [TestClass] public class CartTest { [TestMethod] [ExpectedException(typeof(ArgumentException TestClass] public class CartItemTest { [TestMethod] [ExpectedException(typeof(ArgumentException

    67610发布于 2018-09-10
  • 来自专栏stcnb

    CA1065:不要在意外的位置引发异常

    System.InvalidOperationException 和所有派生项(包括 System.ObjectDisposedException) System.NotSupportedException 和所有派生项 System.ArgumentException System.InvalidOperationException 和所有派生项(包括 System.ObjectDisposedException) System.NotSupportedException 和所有派生项 ArgumentException 例如,如果 Equals 传递两个不匹配的类型,则应只返回 false 而不是引发 ArgumentException。 采用参数的 GetHashCode 版本可能会引发 ArgumentException。 但是,Object.GetHashCode 应始终不会引发异常。

    1K20编辑于 2022-01-11
  • 来自专栏林德熙的博客

    C#委托

    Thread.CurrentThread.ManagedThreadId); } 如果使用的BeginInvoke,那么在委托多播使用 BeginInvoke 会报异常 System.ArgumentException } private static void M1() { p(); throw new ArgumentException (); } private static void M2() { p(); throw new ArgumentException (); } private static void M2() { p(); throw new ArgumentException BeginInvoke(null, null, (e) => { }, null); private static EventHandler _event; 异常:System.ArgumentException

    59630编辑于 2022-08-04
  • 来自专栏魂祭心

    原 大数运算

    { if (string.IsNullOrEmpty(lOperand) || string.IsNullOrEmpty(rOperand)) throw new ArgumentException { if (string.IsNullOrEmpty(lOperand) || string.IsNullOrEmpty(rOperand)) throw new ArgumentException { if (string.IsNullOrEmpty(lOperand) || string.IsNullOrEmpty(rOperand)) throw new ArgumentException { if (string.IsNullOrEmpty(lOperand) || string.IsNullOrEmpty(rOperand)) throw new ArgumentException { if (string.IsNullOrEmpty(lOperand) || string.IsNullOrEmpty(rOperand)) throw new ArgumentException

    78150发布于 2018-05-17
  • 来自专栏全球技术精选

    使用 C# 9 的records作为强类型ID - 路由和查询参数

    string s => new ProductId(int.Parse(s)), null => null, _ => throw new ArgumentException ProductId id => id.Value.ToString(), null => null, _ => throw new ArgumentException ($"Cannot convert {value} to string", nameof(value)) }; } throw new ArgumentException IsStronglyTypedId(stronglyTypedIdType)) throw new ArgumentException($"Type '{stronglyTypedIdType stronglyTypedIdType.GetConstructor(new[] { typeof(TValue) }); if (ctor is null) throw new ArgumentException

    2.7K20发布于 2021-01-21
  • 来自专栏张善友的专栏

    编写前置和后置条件的连贯接口库:CuttingEdge.Conditions

    IsInRange(1, 999)    // ArgumentOutOfRangeException on failure         .IsNotEqualTo(128);   // throws ArgumentException on failure     Condition.Requires(xml, "xml")         .StartsWith("<data>") // throws ArgumentException on failure         .EndsWith("</data>"); // throws ArgumentException on failure     Condition.Requires IsNotNull()          // throws ArgumentNullException on failure         .IsEmpty();           // throws ArgumentException

    68270发布于 2018-01-19
  • 来自专栏软件开发

    C#快速读写文件

    // // 异常: // System.ArgumentException: // path 是一个零长度字符串,仅包含空白或者包含一个或多个由 // // 异常: // System.ArgumentException: // path 是一个零长度字符串,仅包含空白或者包含一个或多个由 // // 异常: // System.ArgumentException: // path 是一个零长度字符串,仅包含空白或者包含一个或多个由 // // 异常: // System.ArgumentException: // path 是一个零长度字符串,仅包含空白或者包含一个或多个由 // // 异常: // System.ArgumentException: // path 为空、只包含空白、包含无效字符或文件属性无效。

    4.3K90发布于 2018-01-04
  • 来自专栏林德熙的博客

    dotnet C# 如何修改异常的堆栈

    ExceptionDispatchInfo 机制 实现方法非常简单,通过 ExceptionDispatchInfo.SetRemoteStackTrace 方法即可修改异常堆栈,如以下示例 var exception = new ArgumentException {nameof(Foo.F1)} Main"); Console.WriteLine(exception); 此时控制台输出内容大概如下 System.ArgumentException: Value stack trace from previous location --- 如果想要对外抛出此加工后的异常,直接使用 throw exception; 扔掉即可,异常打印信息大概如下 System.ArgumentException ExceptionDispatchInfo.Throw 扔也可以,代码示例如下 ExceptionDispatchInfo.Throw(exception); 异常打印信息大概如下 System.ArgumentException

    20710编辑于 2025-09-06
  • 来自专栏技术之路

    【数据结构】带头结点的链表实现

    void add(int index,E e) { if (index < 0 || index > size) throw new ArgumentException public E get(int index) { if (index < 0 || index >= size) throw new ArgumentException set(int index ,E e) { if (index < 0 || index >= size) throw new ArgumentException E remove(int index) { if (index < 0 || index >= size) throw new ArgumentException

    21610编辑于 2024-04-23
  • 来自专栏DotNet NB && CloudNative

    5 分钟 .NET 单元测试极简入门

    >() // 验证是否抛出 ArgumentException 异常 .WithMessage("Author name cannot be null or empty"); // 验证异常消息是否正确 而当传入 null 或 "" 时,都应该抛出 ArgumentException,而且异常信息为 Author name cannot be null or empty。 >() // 验证是否抛出 ArgumentException 异常 .WithMessage("Year cannot be negative"); // 验证异常消息是否正确 } >() // 验证是否抛出 ArgumentException 异常 .WithMessage("Year cannot be negative"); // 验证异常消息是否正确 } >() // 验证是否抛出 ArgumentException 异常 .WithMessage("Start year cannot be greater than end year")

    1.2K50编辑于 2023-08-30
  • 来自专栏C#

    免费开源的.NET多类型文件解压缩组件SharpZipLib(.NET组件介绍之七)

    count", "Cannot be negative"); } if ((buffer.Length - offset) < count) { throw new ArgumentException { if (string.IsNullOrEmpty(fileToZip)) { throw new ArgumentException { if (string.IsNullOrEmpty(strDirectory)) { throw new ArgumentException { if (string.IsNullOrEmpty(zipedFile)) { throw new ArgumentException } if (string.IsNullOrEmpty(password)) { throw new ArgumentException

    2.4K60发布于 2018-01-04
领券