草庐IT

it_begin

全部标签

c# - WCF 服务引用 - 在客户端获取 "XmlException: Name cannot begin with the ' <' character, hexadecimal value 0x3C"

我有一个智能客户端应用程序通过WCF与其服务器进行通信。数据在客户端创建,然后通过服务发送以进行持久化。服务器和客户端通过共享dll使用相同的域类,我在VisualStudio中使用方便的“添加服务引用”功能来包装SvcUtil.exe并生成客户端和代理类。尝试调用该服务时出现以下错误:System.Xml.XmlExceptionoccurredMessage=Namecannotbeginwiththe'这特别麻烦,因为该服务一次可以运行数周而不会出现此错误,然后突然又没有警告地再次出现。我一直无法弄清楚是什么原因造成的。当它确实发生时,我将深入研究如何修复它并且通常不会想出比那些

c# - 将 It.IsAny<int>() 和 It.IsAny<int>() 的值传递给方法设置有什么区别

我正在使用Moq,并希望创建构建器类来创建具有预设合理默认值的模拟,这些默认值可以在测试设置期间根据需要覆盖。我采用的方法使用扩展方法,我在其中传递输入参数值和预期输出。这样做时,我看到在我看来语义等效的代码中有不同的行为:直接在设置中传递It.IsAny()与在设置中间接传递It.IsAny()的值。示例:publicinterfaceIFoo{boolBar(intvalue);boolBar2(intvalue);}publicclassFoo:IFoo{publicboolBar(intvalue){returnfalse;}publicboolBar2(intvalue){r

c# - 使用 Moq.It.IsAny 测试以某物开头的字符串

是否可以使用Moq来表示一个方法接受以“ABC”开头的字符串。举个例子:logger.Verify(x=>x.WriteData(Moq.It.IsAny().StartsWith("ABC")),Times.Exactly(3));那不会编译,但希望它能说明我的观点 最佳答案 尝试:logger.Verify(x=>x.WriteData(Moq.It.Is(str=>str.StartsWith("ABC"))),Times.Exactly(3));你可以看到It.Is的另一个例子://matchingFunc,lazyeval

c# - "This BackgroundWorker states that it doesn' t 报告进度。”- 为什么?

我是这个后台worker的新手我已经阅读了一些关于如何创建一个的文章这是它产生的privatevoidbackgroundWorker1_DoWork(objectsender,DoWorkEventArgse){Bitmapimgbox=newBitmap(pictureBox.Image);intimgHeight=imgbox.Height;intimgWidth=imgbox.Width;intcounter=1;MinMaxWidth=imgWidth-50;MaxWidth=imgWidth;try{Colorc;//Colorc2;for(inti=0;i但是当我开始Do

c# - VS 2017 : The security debugging option is set but it requires the Visual Studio hosting process which is unavailable

我的解决方案(包含十几个项目)在VisualStudio2013中完美运行。在VisualStudio2017中,我可以打开解决方案并进行编译。但如果我开始调试,我会系统地收到此错误消息:ThesecuritydebuggingoptionissetbutitrequirestheVisualStudiohostingprocesswhichisunavailableinthisdebuggingconfiguration.Thesecuritydebuggingoptionwillbedisabled.Thisoptionmaybere-enabledintheSecuritypro

c# - 错误 : Reference to type claims it is defined, 但找不到

我有一个包含3个项目的解决方案:ParsersBase,它定义了一个接口(interface)IParseRuleParsersLibrary,它引用了ParsersBase并定义了一个类HtmlImageUrlParseRule:IParseRuleParsersLibraryTest,它引用了ParsersBase和ParsersLibrary并定义了一个带有一些测试方法的测试类当我尝试构建它时,我收到警告:Referencetotype'AVSoft.ParsersBase.IParseRule'claimsitisdefinedin'c:\Users\Tim\Dropbox\p

c# - 获取 "Tuple element name is inferred. Please use language version 7.1 or greater to access an element by its inferred name."

直到今天,在我们将VisualStudio2017更新到最新的15.3之后,我们的UWP应用程序中的以下代码一直运行良好。privatevoidTest(){vargroups=newListitems)>();varitems=newList{("a",true),("b",false),("c",false)};vargroup=(Guid.NewGuid(),items);groups.Add(group);}在输出窗口中没有错误信息但是这个Tupleelementname'items'isinferred.Pleaseuselanguageversion7.1orgreater

c# - 生成错误 : "The process cannot access the file because it is being used by another process"

我有一个C#webforms应用程序,直到今天它一直运行顺畅。现在,突然之间,每次我尝试运行该应用程序时,我都会收到文件锁定错误:Unabletocopyfile"obj\Debug\MyProject.exe"to"bin\Debug\MyProject.exe".Theprocesscannotaccessthefile"bin\Debug\MyProject.exe"becauseitisbeingusedbyanotherprocess.谷歌搜索错误并没有发现明显的错误,即VS认为文件已锁定。绝对锁定文件的是VisualStudio本身,因为当我关闭VS并重新打开它时,项目执行

c# - Stream.Seek(0, SeekOrigin.Begin) 或 Position = 0

当您需要将流重置为开始时(例如MemoryStream),最佳做法是使用stream.Seek(0,SeekOrigin.Begin);或stream.Position=0;我已经看到两者都工作正常,但想知道是否一个比另一个更正确? 最佳答案 设置绝对位置时使用Position,设置相对位置时使用Seek。两者都是为了方便而提供,因此您可以选择适合代码风格和可读性的一种。访问Position要求流是可搜索的,因此它们可以安全地互换。 关于c#-Stream.Seek(0,SeekOrig

c# - 跨线程操作无效 : Control 'textBox1' accessed from a thread other than the thread it was created on

这个问题在这里已经有了答案:Cross-threadoperationnotvalid:Controlaccessedfromathreadotherthanthethreaditwascreatedon(22个答案)关闭6年前。我想使用UART将温度值从微Controller发送到C#接口(interface)并在Label.Content上显示温度。这是我的微Controller代码:while(1){key_scan();//getvalueoftempif(Usart_Data_Ready()){while(temperature[i]!=0){if(temperature[i