草庐IT

win_class

全部标签

c# - cs0030 :Unable to generate a temporary class

我有一个Web服务,当我尝试生成它的对象时出现以下错误。"Unabletogenerateatemporaryclass(result=1).errorCS0030:Cannotconverttype'ShortSell.ShortSellRQOriginDestinationInformationFlightSegment[]'to'ShortSell.ShortSellRQOriginDestinationInformationFlightSegment'errorCS0030:Cannotconverttype'ShortSell.ShortSellRSOriginDestina

c# - 公共(public)静态字符串 MyFunc() 上的 "Expected class, delegate, enum, interface or struct"错误。什么 's an alternative to "字符串”?

当我尝试使用以下静态函数时出现错误。错误:Expectedclass,delegate,enum,interface,orstruct函数(和类):namespaceMyNamespace{publicclassMyClass{//SomeotherstaticmethodsthatuseClasses,delegates,enums,interfaces,orstructspublicstaticstringMyFunc(stringmyVar){stringmyText=myVar;//DosomestuffwithmyTextandmyVarreturnmyText;}}}这导致

c# - OOPS 概念 : What is the difference in passing object reference to interface and creating class object in C#?

我有一个类CustomerNew和一个接口(interface)ICustomer:publicclassCustomerNew:ICustomer{publicvoidA(){MessageBox.Show("Classmethod");}voidICustomer.A(){MessageBox.Show("Interfacemethod");}publicvoidB(){MessageBox.Show("ClassMethod");}}publicinterfaceICustomer{voidA();}我对这两行代码很困惑。ICustomerobjnew=newCustomerNe

c# - 状态条标签中的 String.format() 值在 Win 7 和 Win XP 上显示不同

我正在使用以下代码在我的应用程序的状态栏中显示任务的运行时间。publicvoidDisplayDuration(TimeSpanduration){stringformattedDuration;if(duration.TotalMillisecondsthis.TimingLabel是winform底部的statusStrip控件中的一个标签。但我在WindowsXP和Windows7上得到的结果完全不同WindowsXP:window7为什么单位在Windows7中出现在时间之前?我检查了区域设置,两台机器都设置为美国,日期时间格式相同。非常确定它是在两台机器上运行的相同代码。在

c# - 使用 C#/Win32 将文本写入记事本

我正在弄乱Win32API和Windows消息传递,试图弄清楚它们是如何工作的,我发现了这个questionveryhelpful.我想改进那里提供的解决方案,以便它附加文本,而不是仅仅通过WM_SETTEXT替换记事本中的文本。我的问题是,我将如何使用WM_GETTEXTLENGHT,然后使用WM_GETTEXT来获取记事本窗口中的当前文本,以便我可以在使用WM_SETTEXT之前向其追加新文本?在32位和64位机器上使用WM_XXXTEXT是否都有效?如果记事本中有很多文本,建议的获取/设置算法是否仍然有效,或者它会占用大量资源吗?如果是这样,是否有另一种方法可以将文本附加到记事本

c# - Console/Win 服务应用程序不需要 ConfigureAwait(false),对吗?

我使用async/await有一段时间了,但最近深入研究,并阅读了很多最佳实践提示,默认总是使用ConfigureAwait(false)防止死锁,提高性能。我只是想确保我没有遗漏任何东西,因为我认为这仅适用于实际当前SynchronizationContext或TaskScheduler正在运行的情况,对吗?如果我有一个正在响应消息/命令/等的Windows服务应用程序。异步地,它总是只使用默认的调度程序=可能等待完成的线程池线程将执行延续,因此没有死锁,使用ConfigureAwait(false)也不会产生性能差异,正确?不是我不能把它放在那里,而是我非常讨厌嘈杂的代码.....

c# - 系统.ComponentModel.Win32Exception : Access is denied Error

我正在使用C#代码启动和停止窗口服务,但出现此错误。System.ComponentModel.Win32Exception:Accessisdenied我的代码:publicvoidStartService(stringserviceName,inttimeoutMilliseconds){ServiceControllerservice=newServiceController(serviceName);try{TimeSpantimeout=TimeSpan.FromMilliseconds(timeoutMilliseconds);service.Start();service

c# - ASP.net Web API : change class name when serializing

我有一个产品的数据传输对象类publicclassProductDTO{publicGuidId{get;set;}publicstringName{get;set;}//Otherproperties}当Asp.net序列化JSON(使用JSON.NET)或XML中的对象时,它会生成ProductDTO对象。但是,我想在序列化期间更改名称,从ProductDTO到Product,使用某种属性:[Name("Product")]publicclassProductDTO{[Name("ProductId")]publicGuidId{get;set;}publicstringName{

c# - 低级差异 : non-static class with static method vs. 静态类与静态方法

我想知道使用具有静态方法的非静态类与具有相同静态方法的静态类的一般好处(或缺点)是什么,除了我不能使用非静态类中的静态方法作为扩展方法。例如:classNonStaticClass{publicstaticstringGetData(){return"Thiswasinvokedfromanon-staticclass.";}}与此相比:staticclassStaticClass{publicstaticstringGetData(){return"Thiswasinvokedfromastaticclass.";}}使用一种方法优于另一种方法对性能/内存有何影响?注意:假设我不需要

c# - Win32Exception: 目录名无效

我正在尝试以不同的用户身份运行一个进程,该用户在2台运行Vista且启用了UAC的不同计算机中具有管理员权限,但在其中一台计算机中我收到Win32Exception,提示“目录名称无效”谁能告诉我我的代码有什么问题?varmyFile="D:\\SomeFolder\\MyExecutable.exe";varworkingFolder="D:\\SomeFolder";varpInfo=newSystem.Diagnostics.ProcessStartInfo();pInfo.FileName=myFile;pInfo.WorkingDirectory=workingFolder;