草庐IT

exception-derived

全部标签

c# - 抛出 Win32Exception

我最近编写了很多涉及与Win32API互操作的代码,并且开始思考处理由调用WindowsAPI函数引起的native(非托管)错误的最佳方法是什么。目前,对native函数的调用看起来像这样://NativeFunctionreturnstruewhensuccessfulandfalsewhenanerror//occurred.Whenanerroroccurs,theMSDNdocsusuallytellyouthatthe//errorcodecanbediscoveredbycallingGetLastError(aslongasthe//SetLastErrorflagha

c# - 列表 'Except' 比较 - 忽略大小写

我有两个列表,我想比较它们并找出差异,同时忽略任何大小写差异。我使用以下代码来获取两个列表之间的差异,但它不会忽略大小写差异。IEnumerablediff=list1.Except(list2);ListdifferenceList=diff.ToList();我试过这个:IEnumerablediff=list1.Except(list2,StringComparison.OrdinalIgnoreCase);但Except似乎没有那种字符串大小写检查(所以错误)。我希望有解决办法。 最佳答案 试试这个:)Listexcept=

pytorch_lightning.utilities.exceptions.MisconfigurationException: You requested GPUs: [1] But...

文章目录报错解决办法报错pytorch_lightning.utilities.exceptions.MisconfigurationException:YourequestedGPUs:[1]Butyourmachineonlyhas:[0]笔者的报错代码:trainer=Trainer(max_epochs=config.max_epochs,gpus=[fix_config.hparams.gpus],distributed_backend=fix_config.hparams.distributed_backend,benchmark=fix_config.hparams.benchm

c# - 系统.OutOfMemoryException : Exception of type 'System.OutOfMemoryException' was thrown in angularjs

我已经花了几周的时间来解决这个问题。但我仍然无法解决这个问题。我在angularjs中使用http调用WebAPI服务$http({method:'GET',url:rootUrl+'/api/Project/ProjectList',headers:{'Content-Type':"application/json;charset=utf-8"}}).success(function(response){$scope.ProjectList=response;}).error(function(response,errorCode){if(errorCode==444){}})我在服

c# - 为什么 Resharper 使用此代码说 "Co-variant array conversion from string[] to object[] can cause run-time exception on write operation"?

这个问题在这里已经有了答案:Co-variantarrayconversionfromxtoymaycauserun-timeexception(7个答案)关闭7年前。这段代码:comboBoxMonth.Items.AddRange(UsageRptConstsAndUtils.months.ToArray());publicstaticListmonths=newList{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};提示“从string[]到object[]的Co-variant数

c# - 系统.IO.Exception : Pipe is broken

我有两个.NET应用程序,它们通过命名管道相互通信。第一次一切都很好,但是在发送第一条消息后,服务器将再次监听,WaitForConnection()方法抛出一个System.IO.Exception消息管道坏了。为什么我在这里得到这个异常(exception)?这是我第一次使用管道,但在过去使用套接字时,类似的模式对我有用。代码啊!服务器:usingSystem.IO.Pipes;staticvoidmain(){varpipe=newNamedPipeServerStream("pipename",PipeDirection.In);while(true){pipe.Listen(

c# - 为什么不能将 List<Derived> 分配给 List<Base>?

我定义了以下类:publicabstractclassAbstractPackageCall{...}我还定义了这个类的一个子类:classPackageCall:AbstractPackageCall{...}AbstractPackageCall还有其他几个子类现在我想进行以下调用:Listcalls=package.getCalls();但我总是得到这个异常(exception):Error13Cannotimplicitlyconverttype'System.Collections.Generic.List'to'System.Collections.Generic.List

c# - "Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))"

我正在尝试使用一个应用程序,该应用程序运行良好,我正在尝试编辑应用程序中的现有项目。单击编辑时出现以下错误,System.Runtime.InteropServices.COMExceptionwasunhandledMessage="Classnotregistered(ExceptionfromHRESULT:0x80040154(REGDB_E_CLASSNOTREG))"Source="System.Windows.Forms"ErrorCode=-2147221164StackTrace:atSystem.Windows.Forms.UnsafeNativeMethods.C

c# - 如果 Exception 过滤器的过滤器抛出异常会发生什么

我还没有使用过C#6,但我想知道......正如标题所说“如果Exception过滤器的过滤器抛出异常会发生什么?”。我想真正的答案是“过滤器应该以永远不会抛出异常的方式编写。”,但可以说它确实如此。会不会好像异常发生在捕获本身内部?try{thrownewException("ForcedException");}catch(Exceptionex)when(MethodThatThrowsAnException()){WriteLine("Filteredhandler1");}catch(Exceptionex){WriteLine("Filteredhandler2");}或者

c# - 如何在c#中使用列表中的Except方法

我已经创建了一个两个int类型的列表,并使用except方法将仅在list1中的项目分配给list1。例如Listlist1=newList();Listlist2=newList();list1={1,2,3,4,5,6}//getitemsfromthedatabaselist2={3,5,6,7,8}//getitemsfromthedatabaselist1=list1.Except(list2);//givesmeanerror.请给我建议。什么是正确的做法。 最佳答案 Except方法返回IEnumerable,需要将结