草庐IT

c# - SqlCommand.Cancel() 导致性能提升?

我已经看到它出现在代码中的几个地方,从来没有解释,只是在它上面的一个神秘注释(声明和执行包括上下文的概念。它只是运行SqlCommand的标准过程)://SqlCommandcmd=newSqlCommand();//cmd.ExecuteReader();//Readofftheresults//Cancelthecommand.Thisimprovesquerytime.cmd.Cancel();基本上,在完成查询后,它会返回并取消它,声称性能有所提升。我想您可能会在它消失并释放XmlReader时取回一些内存,但通常它无论如何都会超出范围。我以前从来没有为它烦恼过,但它终于出现在

c# - 将 PDF 查看器添加到 WPF 应用程序

我是WPF的新手,正在尝试将PDF查看器添加到我的WPF应用程序,但似乎无法弄清楚如何去做......我已经尝试按照我拥有的几个教程/示例进行操作在网上找到的,但由于各种原因它们似乎对我不起作用...例如,我尝试按照教程进行操作:https://documentation.devexpress.com/#WPF/CustomDocument114328在设计时添加PDF查看器-它说到dragthePdfViewerControlfromtheDX.15.2:Data&AnalyticsToolboxtabanddropitontothemainwindow但是,我好像没有Data&An

c# - 错误 (HttpWebRequest) : Bytes to be written to the stream exceed the Content-Length bytes size specified

我似乎无法弄清楚为什么我不断收到以下错误:BytestobewrittentothestreamexceedtheContent-Lengthbytessizespecified.在以下行:writeStream.Write(bytes,0,bytes.Length);这是一个Windows窗体项目。如果有人知道这里发生了什么,我肯定会欠你一个。privatevoidPost(){HttpWebRequestrequest=null;Uriuri=newUri("xxxxx");request=(HttpWebRequest)WebRequest.Create(uri);request

c# - Microsoft Office 互操作性能问题

我尝试在我的C#4.0Windows应用程序中将datagridview数据导出到excel文件。我们使用了Microsoft.Office.Interop.Exceldll版本12.0.0.0。一切都很好很好。但是当我尝试导出超过1000条datagridview记录时,它花费的时间太长了时间。我怎样才能提高性能。请参阅下面的Excel帮助程序代码。usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.IO;usingMicrosoft.Office.Inte

c# - 无效操作异常 : No IAuthenticationSignInHandler is configured to handle sign in for the scheme: MyCookieAuthenticationScheme

我正在尝试按照说明进行操作here将Cookie身份验证添加到我的网站。到目前为止,我添加了以下内容:InvoketheUseAuthenticationmethodintheConfiguremethodoftheStartup.csfile:app.UseAuthentication();InvoketheAddAuthenticationandAddCookiemethodsintheConfigureServicesmethodoftheStartup.csfile:services.AddAuthentication("MyCookieAuthenticationScheme

c# - LINQ to Entities/LINQ to SQL : switching from server (queryable) to client (enumerable) in the middle of a query comprehension?

在许多情况下,我想在服务器端进行一些过滤(有时是投影),然后切换到客户端以执行LINQ提供程序本身不支持的操作。天真的方法(这基本上就是我现在所做的)是将其分解为多个查询,类似于:varfromServer=fromtincontext.Tablewheret.Col1=123wheret.Col2="blah"selectt;varclientSide=fromtinfromServer.AsEnumerable()wheret.Col3.Split('/').Last()=="whatever"selectt.Col4;但是,很多时候,这带来的代码/麻烦多于它的实际值(value)

c# - "The type or namespace name ' 引用System.Xml.dll时XmlSerializer ' could not be found"错误

我已经在这上面浪费了几个小时:XmlSerializerserializer;是的,using在那里,引用在那里,我在VS2010中使用.NET4.0制作了整个解决方案,所以它不是那些东西。如果我进入对象资源管理器,我可以在正确的命名空间中找到我想要的XmlSerializer类,但是如果我尝试在我的代码文件中键入上面的行并进行编译,我会得到可怕的Thetypeornamespacename'XmlSerializer'couldnotbefound(areyoumissingausingdirectiveoranassemblyreference?)死亡警告。我也没有在Intelli

c# - Visual Studio 2017 : "Object reference not set to an instance of an object" while loading the project

我在VS解决方案中有一个项目可以在VS2015中正确加载,但它似乎在VS2017(RC2)中已损坏。在解决方案资源管理器中,它显示其“加载失败”,当我尝试重新加载它时,我收到一个错误弹出窗口,消息为“对象引用未设置为对象的实例”。我认为这可能是因为VS2017以某种方式更改了.csproj文件以满足他们的需要,但是在将它与VS2015解决方案中的版本进行比较后我发现它们并没有什么不同。有人遇到过这样的事情吗?以及如何修复它?谢谢。 最佳答案 对于VisualStudio2017的我来说,这些建议都没有奏效。有效的方法是关闭所有Vis

c# - 如何重启控制台应用程序?

我需要在用户按“R”时重新启动应用控制台。我有这个Console.WriteLine(message,"RebuildLogFiles"+"PressEntertofinish,orRtorestartheprogram...");stringrestar=Console.ReadLine();if(restar.ToUpper()=="R"){//herethecodetorestarttheconsole...}谢谢 最佳答案 //StartsanewinstanceoftheprogramitselfSystem.Diagno

c# - 使用 .NET Core MSTest 运行单元测试 : "The following TestContainer was not found..."

我到处搜索,找不到这个异常的答案。Thisquestion是我搜索时出现的主要问题,但它没有解决这个问题。[7/8/20186:22:22PMInformational]Executingtestmethod'CoreScraper.FlyerScraper.GetAllCurrentFlyers'[7/8/20186:22:22PMError]System.InvalidOperationException:ThefollowingTestContainerwasnotfound'C:\Users\Username\Documents\VisualStudio2017\Project