草庐IT

the_exception

全部标签

c# - 使用 SmtpClient 发送电子邮件时的故障排除 "Mailbox unavailable. The server response was: Access denied - Invalid HELO name"

我一直在尝试通过C#发送电子邮件。我在Google上搜索了各种示例,并从每个示例和每个人最有可能使用的标准代码中提取了点点滴滴。stringto="receiver@domain.com";stringfrom="sender@domain.com";stringsubject="HelloWorld!";stringbody="HelloBody!";MailMessagemessage=newMailMessage(from,to,subject,body);SmtpClientclient=newSmtpClient("smtp.domain.com");client.Crede

c# - Log4net - 禁止将 "exception"附加到自定义 "PatternLayout"

当使用自定义“PatternLayout”时,log4net会将“异常”信息(如果存在)附加到每个日志条目。我正在尝试控制消息和堆栈跟踪信息的输出,并希望“抑制”此信息。我四处搜寻,但找不到办法。有什么想法吗?示例web.config条目(对于RollingFileAppender):谢谢 最佳答案 像这样配置布局:...将IgnoresException设置为false告诉appender布局将处理异常。因此您可以选择不打印堆栈跟踪。 关于c#-Log4net-禁止将"exceptio

c# - 挣扎于最小起订量 : The following setups were not matched

我是第一次使用Moq,我正在努力让测试正常运行。我正在尝试最小化服务层的Save()方法。publicvoidSave(UserViewModelviewModel){//todo:thisstilldoesn'taddressupdatingapassword.TheUserViewModeldoesn'tcontainanyPassworddata.if(viewModel.Id!=Guid.Empty){//TheUserIdisnotempty,we'reeitherupdatinganexistinguser//orwe'reinsertinganewuserviasyncv

c# - 玻璃映射器 : InferType is ignored when querying the SitecoreContext

我已经在我的Sitecore7.1解决方案上安装了Glass.Mapper.Sc.CaSTLeWindsor版本3.1.2.11包,并尝试使用推断类型。我有以下类(class):[SitecoreType]publicclassServiceConfiguration{[SitecoreField(FieldName="ServiceId")]publicvirtualstringServiceId{get;set;}}[SitecoreType(TemplateId="{26512C19-8D30-4A1E-A2CD-3BA89AF70E71}")]publicclassJavasc

c# - 无效的 URI : The Authority/Host could not be parsed from very long url

这是Youtube视频的实际url,此时如果您复制到您的chrome浏览器,您可以观看该视频。但是,当我尝试创建请求时,我得到了UriFormatException。我做错了什么?HttpWebRequestrequest=(HttpWebRequest)HttpWebRequest.Create(url);http:/r6---sn-x5jjxnn-ogul.googlevideo.com/videoplayback?ratebypass=yes&ms=au&fexp=924615,912522,932260,910207,936330,916611,936117,936910,93

c# - 为什么 Enumerable.Except 返回不同的项目?

刚刚花了一个多小时调试我们代码中的一个错误,最终证明是关于Enumerable.Except的错误。我们不知道的方法:varilist=new[]{1,1,1,1};varilist2=Enumerable.Empty();ilist.Except(ilist2);//returns{1}asopposedto{1,1,1,1}或更一般地说:varilist3=new[]{1};varilist4=new[]{1,1,2,2,3};ilist4.Except(ilist3);//returns{2,3}asopposedto{2,2,3}查看MSDN页面:Thismethodretur

c# - Entity Framework 给出异常 : "The underlying provider failed on Open."

我有一个测试。发生的情况是,无论何时首先执行test1,test2都会失败并显示消息:"System.Data.EntityException:System.Data.EntityException:theunderlyingproviderfailedonopen.cannotopendatabase"DBEntities"requestedbythelogin.Theloginfailed.".只要先执行test2,test1就会失败并显示相同的消息。过去3天我一直在处理这个问题。[TestClass]classMyTestClass{DBEntitiesdb;[TestIniti

c# - EventLogReader 和 EventRecord : Where's the Message?

我想查询远程机器上的应用程序事件日志,我求助于使用EventLogReader而不是EventLog因为它需要很长时间才能找到事件我需要EventLog。然而,尽管使用EventLogReader可以更快地找到事件,但我还是无法弄清楚我需要的信息在这个对象上到底在哪里……尤其是消息。publicstaticvoidLoad(){stringquery="*[System/Provider/@Name=\"SQLSERVERAGENT\"]";EventLogQueryelq=newEventLogQuery("Application",PathType.LogName,query);e

c# - EF lambda : The Include path expression must refer to a navigation property

这个问题在这里已经有了答案:EF:Includewithwhereclause[duplicate](5个答案)关闭5年前。这是我的表达:Coursecourse=db.Courses.Include(i=>i.Modules.Where(m=>m.IsDeleted==false).Select(s=>s.Chapters.Where(c=>c.IsDeleted==false))).Include(i=>i.Lab).Single(x=>x.Id==id);我知道原因是模块部分的Where(m=>m.IsDeleted==false),但为什么会导致错误?更重要的是,我该如何修复它

C# - 线程中止异常(Thread Abort Exception)重新抛出自身

我有当前代码:classProgram{privatestaticvoidMain(){while(true){try{Thread.CurrentThread.Abort();}catch(ThreadAbortException){Console.WriteLine("Abort!");Thread.ResetAbort();}Console.WriteLine("nowwaiting");Console.ReadKey();}}}现在我知道ResetAbort方法应该可以防止ThreadAbortException继续重新抛出自身,即使catch语句正在捕获它,但我的问题是:如果