Tuesday, October 10, 2006

FatalExecutionEngineError with EventPool

At work I have been converting our product to Visual Studio.Net 2005. After Visual Studio converted the solution, and I fixed all the compiler warnings caused by stuff that has been obsoleted in the .Net Framework 2.0, I pressed F5 to run. The app started up successfully, but when I tried any functionality, I got a nasty error:

FatalExecutionEngineError was detected
Message: The runtime has encountered a fatal error. The address of the error was at 0x79f783dd, on thread 0x5d0. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

The error was presented in a Managed Debugging Assistant (MDA), which is something new for Visual Studio.Net 2005:


I tracked the issue down to a call in some EventPool code that we got from Marc Clifton's site. There was a demo program (EventPoolDemo.zip; you need to register with the site to be able to see the download link) available, so I downloaded it and loaded the solution in Visual Studio.Net 2005. The solution was written in Visual Studio.Net 2003, so the conversion wizard popped up and converted it without any issue. I pressed F5 to run, and Presto, I hit the same error.

I next checked the forums on Marc's site and discovered that someone else had hit this issue too. Unfortunately, nobody had posted a response. I decided to drop a line to Marc to see if he had any clues.

I spent the rest of the day banging my head against the wall trying to figure out the issue by debugging and Googling. I made no progress and by the end of the day had a real headache.

And then, as I was ready to throw in the towel for the day, up popped an email reply from Marc.

Hi Darryl,

See if the solution posted in this link solves the problem.

http://www.codeproject.com/csharp/eventpool.asp?msg=1541283#xx1541283xx

Marc

Holy deus ex machina, Batman, it worked! The problem was a naming conflict in the EventPool code. All I had to do was rename a delegate that conflicted with System.MulticastDelegate from this:

protected delegate void MulticastDelegate(object sender, EventArgs e);

to this:

protected delegate void EpMulticastDelegate(object sender, EventArgs e);

Hooray, the app is working again! Until I hit the next conversion issue...



Friday, October 06, 2006

Araxis Merge with Rational ClearCase

About a year ago I finally got tired of the Diff tool that comes with Microsoft Visual Source Safe (VSS). A little Googling pulled up this Coding Horror post on Araxis Merge.

After a quick download and 30 day free trial, I was hooked. It is sooooooo sweet, and if you've never used anything better than the dumb VSS Diff, you don't know what you're missing. Then the 30 days came to an end.

Cheap, it is not. But hey, I rationalized: I'm a developer, and a good Diff tool is essential for the toolbox. I found that I was easy to convince. So, I bought it for myself with my own Buckazoids (more on those here, if you're interested). Since then have used it nearly every day, and it makes doing a diff nearly enjoyable. It was well worth the cost, and I only wish I had found it years earlier.

But then I changed jobs, and joined a place where Rational ClearCase is used. The ClearCase Diff tool was better than VSS' tool, but I preferred to stick with my beloved Araxis Merge. How to integrate it with ClearCase?

Fortunately Araxis had a page devoted to this topic, and an entry for ClearCase. This led me to Ganesh Viswanathan's nifty Clearaxis utility. A quick download and Presto, I was back in business with Merge.

After a few days of use, I noticed a little problem with Clearaxis: files in paths with embedded spaces would not load into Merge properly. I sent an email to Ganesh, and within a few days, he had provided me with a fix to try out, and it worked like a charm. Now that's terrific support. If you use ClearCase and Araxis Merge, you need Clearaxis!

Thursday, September 28, 2006

Shredding a file in C#

A possible project that I have in mind would have the need to shred a file. That is, not just to delete the file, but to wipe its contents from the disk such that a snoop with the right tools would be unable to recover it.

How to do this in C#? I knew there were tools that do this, but I'd never come across any code that does it. Trusty Google turned up a post by Darrell Hawley (whose parents gave him a great name but alas, spelled it incorrectly) who pondered the same question.

Resuming my search, I found a great article by Gregory A. Wolking from 2001: Shred Deleted Files. Unfortunately, the source was not available for free. Cheapskate that I am, I kept looking, and finally found the source (SHRED.ZIP) here.

I took a quick look at the C++ source and found that the task didn't seem as involved as I had thought that it might be. A key point in the code seemed to be opening the file with disabled write caching via the FILE_FLAG_WRITE_THROUGH flag. I Googled that flag and found a C# article named .NET cryptography library for files and strings which uses the flag in a method named OpenFileForSecureOverwrite(). Perfect!

That's about as far as I got, but these resources should be a good starting point if that project of mine ever gets beyond a germ of an idea.