Error Handling Scsf
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Exception Handling in SCSF up vote 1 down vote favorite I have a SCSF application i am trying to handle most of the exceptions using Application.ThreadException += new ThreadExceptionEventHandler(new ThreadExceptionHandler().ApplicationThreadException); The event handler :- public class ThreadExceptionHandler { public void ApplicationThreadException(object sender, ThreadExceptionEventArgs e) { MessageBox.Show(e.Exception.Message, "An exception occurred:", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Works fine . I can catch all the application exceptions in this block. But the problem is after handling the exception the code again goes and executes the same exception generating code again. This happens till the time I get a windows message windows to send the error info to microsoft. Could any one please help in telling me where I might be going wrong. Thanks in Advance Vikram Note :- Currently i am throwing New Exception("Test Exception"); from a button event. I am doing this to provide event handling in my application. c# .net winforms exception share|improve this question edited Nov 27 '09 at 13:17 asked Nov 27 '09 at 12:41 Vikram I Code 57110 You'll need to document what kind of code is throwing the exception. –Hans Passant Nov 27 '09 at 12:49 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote You have to set Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); See this MSDN page for e
SCSF/CAB Unit Tests ★★★★★★★★★★★★★★★ mpuleioMarch 19, 20082 0 0 0
The SCSF project was getting a weird error with the unit tests that were brought forward from VS2005 to VS2008. All the unit tests would pass, however the test run would fail with the following error in a special log file: One of the background http://stackoverflow.com/questions/1808551/exception-handling-in-scsf threads threw exception: System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.at System.Windows.Input.TextServicesContext.StopTransitoryExtension()at System.Windows.Input.TextServicesContext.Uninitialize(Boolean appDomainShutdown)at System.Windows.Input.TextServicesContext.OnAppDomainUnloaded(Object sender, EventArgs args) Of course, we had hundreds of these messages, and no way to correlate them with a specific unit test. After some work, https://blogs.msdn.microsoft.com/mpuleio/2008/03/19/weird-com-exceptions-in-scsfcab-unit-tests/ I was able to find a single repro case. After some research, it looks like any unit test that creates a Window of any type will do this. The fix is to add a TestCleanup method to your fixture like this one: // Added a TestCleanup method to deal with the fact that the code was throwing an InvalidComObjectException// with the information "COM object that has been separated from its underlying RCW cannot be used."// Fix is based on this bug logged on Connect.Microsoft.Com:// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=318333[TestCleanup]public void CleanUp(){ System.Windows.Threading.Dispatcher.CurrentDispatcher.InvokeShutdown();} I know that unit tests that create Windows are not ideal, but for things like CAB and SCSF ( code bases I inherited) it may be necessary. I hope this helps anyone else who runs into this issue. Tags .NET C# Development Tools Smart Client Software Fmvp, SCSF, Smart Client Software Factory, Visual Studio -- Tags: beginners guide, CAB, Composite Application Block, Guidance Automation Package, Model-View-Presenter, mvp, SCSF, Smart Client Software Factory -- richnewman @ https://richnewman.wordpress.com/category/smart-client-software-factory/ 4:57 pm Introduction Part 23 and part 24 of this series of http://www.codeproject.com/Articles/18155/Testing-CAB-and-SCSF-smart-clients-made-easy articles described the Model-View-Presenter pattern. This article explains how the Smart Client Software Factory supports this pattern by generating appropriate classes. Guidance Automation Packages in the Smart Client Software Factory We saw how we could use the Smart Client Application Guidance Automation Package to set up error handling a Smart Client Application in part 18. We can also set up a Model-View-Presenter pattern in a Smart Client application using another of the Guidance Automation Packages. This will only work in an existing Smart Client Application. Running the Model-View-Presenter Package To use the Guidance Automation Package we right-click in Solution Explorer on a project or folder where we error handling scsf want to run the package. It is intended that we do this in the Views folder in a business module. On the right-click menu we select ‘Smart Client Factory/Add View (with presenter)'. We get a configuration screen that lets us name our view, and also lets us put the classes that get created into a folder. For the purposes of this example we name our view ‘Test’, and check the checkbox that says we do want to create a folder for the view. When we click ‘Finish’ we get three classes and a TestView folder as below: Classes Created TestView This is (obviously) our View class. It is intended that this contain the auto-generated code to display the View. As discussed in the previous articles any complex view logic will not go into this class, but will go into the Presenter. TestViewPresenter This is our Presenter class. As discussed in previous articles this should contain logic to deal with user events. It should also contain any complex view logic, and should directly up
Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question about this article Ask a Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Articles » Desktop Development » Smart Client » General ArticleBrowse CodeStatsRevisions (3)Alternatives Comments (8) Add your ownalternative version Tagged as C#C#2.0WinXPWindows.NET2.0Visual-StudioVS2005DevQAArchitect Stats 39.5K views465 downloads44 bookmarked Posted 26 Mar 2007 Testing CAB and SCSF smart clients made easy. hayrob, 26 Mar 2007 CPOL 4.76 (7 votes) 1 2 3 4 5 4.76/5 - 7 votesμ 4.76, σa 0.86 [?] Rate this: Please Sign up or sign in to vote. An explanation