jjzjj

ArgumentOutOfRangeException

全部标签

c# - 部署程序时出现 System.ArgumentOutOfRangeException

目前我正在开发一个可以在连接时检测USB设备的程序。将该设备的所有文件和目录复制到指定文件夹。所有这些都有效。我构建了这个程序,没问题。当我在我的Windows7膝上型电脑(只有一个分区)上运行.exe时,该程序执行它应该执行的操作。当我在另一台Windows7笔记本电脑(有两个分区)和一台WindowsVista笔记本电脑(有两个分区)上测试同一个程序时,我收到此错误消息(荷兰语):System.ArgumentOutOfRangeException:Deindexvaltbuitenhetbereik.Dezemagnietnegatiefzijnenmoetkleinerzijn

c# - ArgumentOutOfRangeException 使用 IndexOf 和 CultureInfo 1031

strings="GewerbegebietWaldstraße";//otherpossibleinput"Waldstrasse"intiFoundStart=s.IndexOf("strasse",StringComparison.CurrentCulture);if(iFoundStart>-1)s=s.Remove(iFoundStart,7);我正在运行CultureInfo1031(德语)。IndexOf将“straße”或“strasse”与定义的“strasse”匹配并返回18作为位置。Remove和Replace都不会因为设置文化而过载。如果我使用删除1个字符删除6

c# - 我应该抛出自己的 ArgumentOutOfRangeException 还是让一个气泡从下面向上冒?

我有一个包装List的类我有通过索引方法获取值:publicRenderedImageInfoGetValue(intindex){list[index].LastRetrieved=DateTime.Now;returnlist[index];}如果用户请求超出范围的索引,这将抛出ArgumentOutOfRangeException。我应该让这种情况发生,还是检查它然后扔掉我自己的?即publicRenderedImageInfoGetValue(intindex){if(index>=list.Count){thrownewArgumentOutOfRangeException(

c# - 将秒数添加到具有 ArgumentOutOfRangeException 的有效 double 结果的 DateTime

下面的代码会崩溃和烧毁,我不明白为什么:DateTimedt=newDateTime(1970,1,1,0,0,0,0,DateTimeKind.Utc);doubled=double.Parse("1332958778172");Console.Write(dt.AddSeconds(d));有人能告诉我这是怎么回事吗?我只是似乎无法弄清楚为什么...编辑此值来自SalesforceRESTAPI,据我所知,它是一个Unix纪元时间戳。“token发行时间,表示为自Unix纪元(1970年1月1日00:00:00UTC)以来的秒数。”解决方案SalesforceRESTAPI实际上在

c# - 这段代码怎么可能: "ArgumentOutOfRangeException: startIndex cannot be larger than length of string"?

我的C#代码中有以下方法://////Removesthefirst(leftmost)occurenceofafroma.//////Thestringtoremovethefrom.Cannotbenull.///Thesubstringtolookforandremovefromthe.Cannotbenull.//////Therestofthe,afterthefirst(leftmost)occurenceoftheinit(ifany)hasbeenremoved.////////////Ifthedoesnotoccurwithinthe,theisreturnedin

System.ArgumentOutOfrangeException:'索引超出范围。必须是非负的,并且小于收藏的大小。”

protectedvoidgetSUM(){//SQLquerythatgetstotalofproductsaleswherecategoryid=1stringSqlQuery=@"SELECTPriceASTotalSalesFROMSTOCKWHEREBarcode='"+TextBox1+"'";//Declareandopenaconnectiontodatabasesqlcon.Open();//CreatesSqlCommandobjectSqlCommandcomm=newSqlCommand(SqlQuery,sqlcon);//GetstotalsalesdecimalT

c# - NetworkStream.Read() 不起作用并抛出 ArgumentOutOfRangeException

只是想创建一个聊天服务器客户端这是等待客户端连接的服务器(可选)*TcpListenerserverSocket=newTcpListener(8888);intrequestCount=0;TcpClientclientSocket=default(TcpClient);serverSocket.Start();Console.WriteLine(">>ServerStarted");clientSocket=serverSocket.AcceptTcpClient();Console.WriteLine(">>Acceptconnectionfromclient");然后,客户端连

c# - 更改控制台窗口的大小会引发 ArgumentOutOfRangeException

我正在尝试在C#控制台应用程序中设置控制台窗口的大小。我收到一个ArgumentOutOfRangeException消息:Thevaluemustbelessthantheconsole'scurrentmaximumwindowsizeof41inthatdimension.Notethatthisvaluedependsonscreenresolutionandtheconsolefont.我正在使用它来设置它:Console.WindowHeight=480;如何正确设置控制台窗口的大小? 最佳答案 来自MSDNConsol