草庐IT

render_not_found

全部标签

c# - 异步任务<IEnumerable<T>> 抛出 "is not an iterator interface type"错误

仅当我使用async时,下面的代码才会抛出isnotaniteratorinterfacetypeawait并包装IEnumerable与任务。如果我删除asyncawait,它将与IEnumerable>一起使用.privateasyncTask>>GetTableDataAsync(CloudTablecloudTable,TableQuerytableQuery)whereT:ITableEntity,new(){TableContinuationTokencontineousToken=null;do{varcurrentSegment=awaitGetAzureTableDa

c# - MSBuild 未处理的异常 : The FileName property should not be a directory unless UseShellExecute is set

版本dotnet核心SDK:2.1.403docker:18.09.7Linux内核:5.0.0-27Ubuntu:18.04.3问题我正在docker中运行一个ASP.NETCore项目。当我docker-composeup时,我得到以下信息:UnhandledException:Microsoft.Build.BackEnd.NodeFailedToLaunchException:TheFileNamepropertyshouldnotbeadirectoryunlessUseShellExecuteisset.--->System.ComponentModel.Win32Exce

c# - iTextSharp 异常 : PDF header signature not found

我正在使用iTextSharp阅读PDF文档的内容:PdfReaderreader=newPdfReader(pdfPath);using(StringWriteroutput=newStringWriter()){for(inti=1;i99%它工作正常。然而,有一个PDF文件有时会抛出这个异常:PDFheadersignaturenotfound.StackTrace:atiTextSharp.text.pdf.PRTokeniser.CheckPdfHeader()atiTextSharp.text.pdf.PdfReader.ReadPdf()atiTextSharp.text

C# - "destructors are not inherited"实际上是什么意思?

C#LanguageSpecification3.0的第10.13节,析构函数声明如下:Destructorsarenotinherited.Thus,aclasshasnodestructorsotherthantheonewhichmaybedeclaredinthatclass.C#ProgrammingGuide的析构函数部分包含一个示例,演示如何调用继承层次结构中的析构函数,包括以下语句:...thedestructorsforthe...classesarecalledautomatically,andinorder,fromthemost-derivedtotheleas

C# 等待与延续 : not quite the same?

看完EricLippert’sanswer我的印象是await和call/cc几乎是同一枚硬币的两面,最多只是句法上的差异。然而,在尝试实际实现时call/cc在C#5中,我遇到了一个问题:要么我误解了call/cc(这很有可能),要么await只是让人想起call/cc。考虑这样的伪代码:functionmain:foo();print"Done"functionfoo:varresult=call/cc(bar);print"Result:"+result;functionbar(continuation):print"Before"continuation("stuff");pr

c# - 我可以将 C# 函数标记为 "this function does not enumerate the IEnumerable parameter"吗?

同一可枚举的多次枚举对我们来说一直是一个性能问题,因此我们尝试在代码中消除这些警告。但是我们有一个通用的扩展函数来抛出空参数异常,它会生成很多这样的警告。它的签名看起来像这样:publicstaticvoidVerifyArgumentIsNotNull(thisTvalue,stringvalueName)whereT:class它所做的只是检查null并抛出一个格式良好且本地化(对于当时正在使用的任何人类语言)的异常。当此函数用于IEnumerable参数时,它会使代码分析警告IEnumerable可能的多次迭代,因为分析器不知道该函数的作用。我想在这个函数上加上一些标签,上面写着

C# 设计 : Why is new/override required on abstract methods but not on virtual methods?

为什么抽象方法需要new/override而虚方法不​​需要?示例1:abstractclassShapesClass{abstractpublicintArea();//abstract!}classSquare:ShapesClass{intx,y;publicintArea()//Error:missing'override'or'new'{returnx*y;}}编译器会显示这个错误:要使当前成员覆盖该实现,请添加override关键字。否则添加新关键字示例2:classShapesClass{virtualpublicintArea(){return0;}//itisvirt

c# - System.Drawing.Graphics.DrawString - "Parameter is not valid"异常

有时,Microsoft的异常消息毫无帮助,令人恼火。我创建了一个漂亮的小MVC方法来呈现文本。方法体如下。当它到达“DrawString”方法时,我得到一个异常抛出说“参数无效”。请注意,据我所知,字体构造正确(我只是使用10pt的Arial),矩形大小为正且看起来有效,画笔为白色SolidBrush,格式标志不影响输出;也就是说,如果我从调用中排除格式标志,我仍然会收到错误消息。DrawString调用就在底部附近。publicActionResultRenderText(stringfontFamily,floatpointSize,stringforeColor,stringb

C# EWS 托管 API : How to access shared mailboxes but not my own inbox

如何连接到交换服务器并从共享邮箱(不是我自己的“myname@mycompany.com”)读取邮件。到目前为止,这是我的代码://CreateaserviceExchangeServiceservice=newExchangeService(ExchangeVersion.Exchange2007_SP1);//Autodiscoverendpointservice.AutodiscoverUrl("someaddress@mycompany.com");FindFoldersResultsfolderSearchResults=service.FindFolders(WellKno

c# - C# 窗体程序中的 "Specified cast is not valid"错误

我遇到“指定的转换无效”错误。C#中的Windows窗体应用程序。我正在尝试从表中检索值。该值要么是smallint,要么是数字(我尝试了两个字段,都给我同样的错误),我尝试将它存储在一个int变量中。这是来源:using(SqlDataReaderrdr=cmd.ExecuteReader())//"select*fromtablewherefieldname="+value{while(rdr.Read()){intnumber=(int)rdr["quantity"];//errorishere 最佳答案 rdr["quant