exception-handling

ServiceHost only supports class service types

落爺英雄遲暮 提交于 2019-12-10 01:04:49
问题 I have a service named WcfService2 (original i know) which has an IService.cs file with a public interface: namespace WcfService2 { [ServiceContract] public interface IService1 { [OperationContract] [WebGet(UriTemplate = "/{value}")] string GetData(string value); } } I then have my public class Service1.svc.cs file which returns a string for the value like so: namespace WcfService2 { public class Service1 : IService1 { public string GetData(string value) { return string.Format("You entered:

Infinite loop invalidating the TimeManager

徘徊边缘 提交于 2019-12-10 01:04:31
问题 I am experiencing a very tricky defect in my WPF application to track down. The error message is: An infinite loop appears to have resulted from repeatedly invalidating the TimeManager during the Layout/Render process. The stack trace (for what it's worth) is: at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) at System.Windows.Threading.ExceptionWrapper

MVC5 AntiForgeryToken - how to handle “The provided anti-forgery token was meant for user ”“, but the current user is ”xxx“.” exception?

随声附和 提交于 2019-12-10 00:55:22
问题 I want to protect our login actions by AntiforgeryToken attribute - I know why the exception from the topic occurs, however I can't seem to find any good solution for it. Let say we have the following situations: It's 8:00 AM, application users are coming to work, they sit down and starting the login process - right now it is very possible that some of the users will get the same ValidationToken . After the first one logs in - all other will see the above exception (or some other custom

Checking module name inside 'except ImportError'

拥有回忆 提交于 2019-12-10 00:50:53
问题 try: import MySQLdb # some action except ImportError as err: # fallback code PyCharm gives a code inspection warning on that: 'MySQLdb' in try block with 'except ImportError' should also be defined in except block This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items. Ok, I thought the warning is reasonable, because

Tweepy Connection broken: IncompleteRead - best way to handle exception? or, can threading help avoid?

落爺英雄遲暮 提交于 2019-12-09 23:53:52
问题 I am using tweepy to handle a large twitter stream (following 4,000+ accounts). The more accounts that I add to the stream, the more likely I am to get this error: Traceback (most recent call last): File "myscript.py", line 2103, in <module> main() File "myscript.py", line 2091, in main twitter_stream.filter(follow=USERS_TO_FOLLOW_STRING_LIST, stall_warnings=True) File "C:\Python27\lib\site-packages\tweepy\streaming.py", line 445, in filter self._start(async) File "C:\Python27\lib\site

Powershell exit does not work

◇◆丶佛笑我妖孽 提交于 2019-12-09 22:38:37
问题 I am writing a script which checks for a registry value and and exits if is 0. (It will proceed if the value is 1.) if ((Get-ItemProperty -path HKLM:\SOFTWARE\ICT\LoginScript).proceed -eq 0) { $form.close() exit } When I run the script with the reg value at 0, it fails to exit and throws an exception instead: System.Management.Automation.ExitException: System error. at System.Management.Automation.FlowControlNode.Execute(Array input, Pipe outputPipe, ExecutionContext context) at System

Handle exceptions with WPF and MVVM

妖精的绣舞 提交于 2019-12-09 19:43:25
问题 I am attempting to build an application using WPF and the MVVM pattern. I have my Views being populated from my ViewModel purely through databinding. I want to have a central place to handle all exceptions which occur in my application so I can notify the user and log the error appropriately. I know about Dispatcher.UnhandledException but this does not do the job as exception that occur during databinding are logged to the output windows. Because my View is databound to my ViewModel the

Exception handling in Linq queries

£可爱£侵袭症+ 提交于 2019-12-09 18:58:35
问题 I m using ... tmpLst = (from e in App.lstAllChilds where e.Id == Id select e).ToList(); where lstAllChilds is the list, which contains some corrupted data as well. So now i m tying to handle Try-Catch block inside this query. Please help. 回答1: Here is the simplest change you can make to simply exclude items which are null or are raising an exception. tmpLst = App.lstAllChilds.Where(e => { try { return e != null && e.Id == Id; } catch { return false; } }).ToList(); But in my opinion you

Is it bad practice to catch RuntimeException for logging purposes?

雨燕双飞 提交于 2019-12-09 18:11:35
问题 I've come across the fact that catching RuntimeException is generally considered bad practice because they can't be corrected and usually are programmer errors. However, we have an (insanely) large application where changes in any part can have unforeseen consequences (Yes, this a problem in and of itself) . Now the idea has come up to start catching and logging RuntimeExceptions at the application's top level so we can be more efficient in fixing such bleed issues as they come up. Like every

64bit exceptions in WndProc silently fail

烂漫一生 提交于 2019-12-09 17:14:35
问题 The following code will give a hard fail when run under Windows 7 32bit: void CTestView::OnDraw(CDC* /*pDC*/) { *(int*)0 = 0; // Crash CTestDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: add draw code for native data here } However, if I try this on Windows 7 64bit, I just get this in the output window: First-chance exception at 0x13929384 in Test.exe: 0xC0000005: Access violation writing location 0x00000000. First-chance exception at 0x77c6ee42 in Test.exe: