http://www.codeproject.com/KB/debug/postmortemdebug_standalone1.aspx
I’m trying to come up with a standard and reliable way to trigger a core dump from within the logging/exception handling of a C# executable. The above article indicates that this should be possible, but it sounds as if making this work across platforms would be a fairly large nightmare.
If anyone has done anything similar to this, I’d be interested to see how you went about it, and if possible maybe we could share/release some code to make this easier.
kieranbenton development debugging, linkpost
Here’s a Channel 9 interview with Anders Hejlsberg, the creator and head designer of C# as a language (as well as Delphi back in the day).
Interesting in that it examines some of the improvements in C# 4.0, as well as features that are being bandied around for even further out.
Also contains the best description of contra-variance and co-variance that I’ve seen so far.
http://channel9.msdn.com/shows/Going+Deep/Expert-to-Expert-Anders-Hejlsberg-The-Future-of-C/
kieranbenton development linkpost
http://flux88.com/blog/net-database-migration-tool-roundup/
Microblog to bring attention to this for myself in the future.
Strategies on how to maintain scripts for database versioning, and how upgrades and downgrades can be managed in a much more automated and reliable fashion than manual scripting.
kieranbenton development linkpost, sqlserver
Quick post to say ‘thanks’! This has suddenly got a whole lot more viable for use as testing/staging boxes outside of the US!
http://www.allthingsdistributed.com/2009/03/expanding_ec2_for_windows.html
kieranbenton news ec2, linkpost
I’ve spent most of today doing some more work on AnthemNxt to continue simplifying the code base and making the framework even more fool proof to work with.
- Separated out the single project into AnthemNxt.Core and AnthemNxt.Controls. For now development will concentrate on Core and further simplifying that. Any patches for Controls will be happily received however as I know many people have their own Anthem controls kicking about.
- Created a dedicated AnthemNxt.Tests web application project which I’ll repopulate with the old Anthem tests at some point, but for now I am using as the basis of my tests for a HttpModule that will simplify Anthem error handling.
- Separated script management out of AnthemNxt.Core.Manager into AnthemNxt.Core.ScriptManager with the intention of eventually allowing the use of this ScriptManager in place of the built in ASP.NET one no matter if you are in a callback or not.
- Created AnthemSection (configuration section handler for web.config) from where the old settings are now read and where any new settings will be placed.
- Created AnthemModule (which is now required to be included in web.config and will be reported as missing if so) which will be used to pave over the slightly manual way in which Anthem used to handle reporting errors back to the browser. The intention is that Application_Error will work identically as it does for postbacks to give you the chance to log information etc, yet redirects to error pages etc from within there will still be honoured using the callback scheme.
I’ve also added two controls of my own:
AdvancedValidationSummary (encompasses all the functionality of ValidationSummary but also allows you to place a control that will catch errors for all validation groups that do not have their own summary control)
CustomValidator (allows code behind to simply set some text to indicate an error, ideal for logic errors where simple validators are not complex enough).
Enough for tonight! Code is committed and builds correctly.
kieranbenton development anthem-nxt
I’ve been struggling with Anthem.NET for some time to work exactly how I would like (and expect) as regards to the event flow for an unhandled page exception.
In the original 1.5.1 release of Anthem, the Application_Error event was bypassed by a hook added in Manager.OnError as follows:
1: private void OnError(object source, EventArgs e)
2: {
3: if (IsCallBack)
4: {
5: _error = HttpContext.Current.Error.ToString();
6: HttpContext.Current.ClearError();
7: WriteResult(HttpContext.Current.Response, null, _error);
8: }
9: }
Which meant that any global logging (we use log4net) of an error that you do in Application_Error does not fire and so you end up with the unsatisfactory situation where errors in callbacks occur silently to your operations team whilst returning correct information back to the JS client portion of Anthem.
This can be worked around by writing a JS Anthem error handler that then calls an AJAX method which triggers a log of a message, but that is convoluted, inefficient and unrelhable and not an acceptable solution for me.
In the latest source of AnthemNxt I’ve removed the above OnError handler and let the exception proceed as a normal postback would (so my Application_Error handler DOES get hit now and I get exceptions fully logged).
However now there is a HTML error page returned to the JS client and not a valid JSON response because the OnUnload Anthem handler is never called (since the page rendering is hijacked due to the exception). Until I can write a HttpModule to overcome this and make AnthemNxt a true drop-in library, I’ve broken out the OnUnload AnthemNxt functionality so that it can be called from Application_Error:
1: private void OnUnload(object sender, EventArgs e)
2: {
3: CompleteRequest();
4: }
5:
6: public void CompleteRequest()
7: {
8: var res = HttpContext.Current.Response;
9:
10: // Handles inserting JS to do a redirect
11: if(Manager.IsCallBack && res.StatusCode == 302)
12: {
13: string href = res.RedirectLocation.Replace("\\", "\\\\").Replace("'", "\\'");
14: res.RedirectLocation = string.Empty;
15: res.Clear();
16: res.StatusCode = 200;
17:
18: var sb = new StringBuilder();
19: Manager.AddScriptForClientSideEval("window.location='" + href + "';");
20: JsonWriter.WriteValueAndError(sb, null, null, null, null, null, null, null, clientSideEvalScripts);
21: res.Write(sb.ToString());
22: res.End();
23: }
24: }
as so:
1: protected void Application_Error(object sender, EventArgs e)
2: {
3: log.Error(ex.Message, ex);
4:
5: // If we are in debug mode get the usual "yellow screen of death" up, makes debugging easier during development
6: if(!Manager.IsCallBack && HttpContext.Current.IsDebuggingEnabled) return;
7:
8: // Redirects to an error page - need to not end the request if this is a callback
9: // so that AnthemNxt can write a JS redirect into the JSON response
10: Response.Redirect(“~/error.aspx”, !Manager.IsCallBack);
11: if(Manager.IsCallBack) Manager.Current.CompleteRequest();
12: }
Hopefully with a HttpModule I can make this fully automatic, but for our purposes this is better than the existing behaviour for now
Anyone interested in contributing, whether it be patches, comments or just bugs please get in touch or use the Codeplex project.
kieranbenton development anthem-nxt
http://www.codeplex.com/anthemnxt
Well I’ve finally done what I’ve been saying I’d do for quite some time now, forked the Anthem.NET project on sourceforge that has gone pretty stale. I’ve started a new codeplex project for the fork with which my immediate aims are to:
- Clean up the codebase
- Incorperate some community and personal bugfixes
- Drop support for .NET 1.1
- Make a beta code release
I’ve already released what I have as a 1.5.2 alpha release so that people just looking for the project can get started easily.
Longer term I’m looking to:
- Refactor the JS code so that it works as a jQuery plugin. Will give greater browser compatibility as well as reducing the size of anthem + jQuery overall (as anthem can use jQuery’s AJAX functionality). This will also make the code much more maintainable.
- Add much more stringent documentation and unit tests.
- Incorperate some new controls that have common uses.
- Find ways to allow easy use of jQuery effects with anthem callbacks
Please let me know what you think. I could do with all the help I can!
kieranbenton development anthem-nxt
Big news today, Mono has finally come of age (probably) and fully supports Windows.Forms along with LINQ and expression trees.
http://www.mono-project.com/Release_Notes_Mono_2.0
Time to try a few of my bigger applications against Mono and re-evaluate just how good it can work in a real production environment.
kieranbenton news linkpost, mono
This is probably one of the coolest things I’ve seen of in a while:
http://aws.typepad.com/aws/2008/10/coming-soon-ama.html
Full blown windows based AMIs are coming to EC2 – so we can do cloud computing on the ASP.NET platform. I’ve emailed them about licensing and performance as these are likely to be not quite as positive as they are with the open source platforms – but I’m hopeful that it will just be at a slightly increased EC2 rate.
kieranbenton news ec2, linkpost
Huge immense cliche I know but this is the first post to my new blog, the last one of which died an awful horrible stagnating death!
I hope to be concentrating on C# / ASP.NET / architecture tips and snippets that will hopefully come in useful to people and also as a place for me to store things that I might not otherwise remember myself!
kieranbenton personal