"Internet Explorer has stopped working" Redux (unfortunately)

OK. Now I'm annoyed. I've already UnBlogged about this here and now I'm seeing it again.

If I use our search facility on eggheadcafe.com and enter "which control posted back" you'll get this url:


When I click on this in IE 7.0 (on Windows Vista, dear Reader...) I get the dreaded "Internet Explorer has stopped working" BS. Some people get this, others don't. For me, the page comes up and almost at the point where the browser has completely loaded it, that's where IE blows up. There's nothing unusual about that page, it's like every other article on the eggheadcafe.com site. Lots of people have reported this issue with lots of different web pages, just because it doesn't happen to you doesn't mean everyone else is nuts, OK? Yeesh! No wonder they call it "Internet Exploder"!

It doesn't matter if I reset IE, it doesn't matter if I run "as Administrator", it doesn't matter if I put IE in as an exclusion in Data Execution Prevention, and it doesn't matter if I run IE "without Add-ons". For what it's worth, I didn't install Vista as an "upgrade" over another OS - it was a clean install. And you better fyookin' believe I'm not gonna take my valuable time to reinstall it and all my software too!

Let me tell you something, Pal:

I have searched for hours (and I happen to be very good at this) and all the King's Fixes and all the King's Hacks couldn't put IE7+ on Window Vista back together again, and now, I AM PISSED OFF.

You got a fix? Post it here. I'm not gonna stand for this crap. I want it fixed. Be aware, if you comment post a fix, it's likely I've already tried it, but I'm willing to try any out that you have and post the results.

The newsgroups and forums are rampant with this stuff, and I say it's time to FIX IT. I've seen hundreds of messages from poor slobs like me who are trying to run a business, or doing work, and in some cases they've had to resort to using Firefox just to be able to search on the .NET for a solution! And, I STILL DON'T HAVE A SOLUTION THAT WORKS.

I don' t give TWO SHITS about your damned Data Execution Prevention, UAE, your stories about not running with add-ons, or any of that other BULLSHIT. I want an operating system with a browser that WORKS, period!

I DON'T CARE about "what printer drivers did you install". I DON'T CARE about this, that or the other thing. I DEMAND an operating system with a built in Internet browser that will WORK, and that will work RELIABLY, CONSISTENTLY, and without ERRORS that interfere with my PRODUCTIVITY. And, I REALLY DO NOT THINK THAT IS TOO MUCH TO ASK.

D00ds, What am I talking here, Greek? How about it! Where I work, the stuff I put into production HAS TO WORK. I DON'T GET the luxury of "Fixes" or "explanations". IT EITHER WORKS, OR I AM OUT OF A JOB.

Get the picture?

N.B. There is one interesting item found by Determina that could be part of the issue. To test out this "ActiveX bgColor" bug, try this code:

<script language="JavaScript">
obj = new ActiveXObject("giffile");

Any page with one of these little boogers in it WILL Crash IE 7.0 on Windows Vista summarily! Here's a live sample(opens in a new window, but it WILL crash your browser, even IE 6.0...). Look, you folks have had years to fix this!

P.S. Don't you just love the "Me too" syndrome? You search a post thread where some geek outlines a problem that they are having, and instead of value in the follow-ups, the NEXT 50 POSTS say, more or less, "Me Too!". Jeesh!


Read / Write Large Value (Blob) Types in SQL Server 2005 with ADO.NET 2.0

I saw somebody's post on the C# newsgroup recently where they had posted some chunked code to use a do / while GetBytes pattern to read from a Varbinary(MAX) column. The code was fine, but it sure was a lot of code, because the individual who posted it was accumulating the entire block of data in memory anyway and then proceeding to use it.

There is a much simpler way, with SQL 2005 and ADO.NET 2.0:

//-- READ - reading a varBinary(MAX) columm...

System.Data.SqlTypes.SqlBytes myBytes;
System.Data.SqlClient.SqlDataReader dr;
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
dr = cmd.ExecuteReader(CommandBehavior.SequentialAccess); // SequentialAccess allows chunked reading with offsets, etc.

myBytes = dr.GetSqlBytes(1); // return a SqlBytes type containing the entire contents of the column
System.IO.Stream s = myBytes.Stream; // get the stream property

Bitmap B = new Bitmap(s);

//-- WRITE

byte[] byteBlobData;
System.IO.FileStream fs = new System.IO.FileStream("myPhoto.jpg",System.IO.FileMode.Open);
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
byteBlobData = br.ReadBytes((int)fs.Length);
cmd.Parameters.Add("@BLOB", SqlDbType.Image, 5000).Value = byteBlobData;
... etc.

Here is the documentation page that summarizes.

[And yes, I did close my streams, my FileStream, BinaryReaders, my SqlDataReader and my Connection. Closed the door, flushed the toilet, put out the dog. I even called Dispose afterward. As Dom Deluise would say, "I hope it's enough!" :-)]


Bong Hits for Jesus, Mescaline for Moses...

Please. Give me a break, OK? This kid wants to exercise his right to free speech on a public sidewalk across from his school's outdoor event, and the fyookin' Principal comes across the street and physically takes down his banner and supends him from school for five days?

Somebody is smoking SOMETHING, but it ain't common sense -- that's for sure!

I should note that this happened in 2002 - it's coming up now because the Supreme Court of the United States agreed to hear it today. This is not a small deal - its a very big deal - but we'll probably have to wait for summer 2007 before the Court rules on it.

Look, I grew up smoking pot. I can't smoke it any more, maybe I'm too old, I don't know - it makes me crazy now. But one thing I know is this - compared to alcohol, pot could be the most innocuous illegal substance there is - provided you have enough sense not to go driving on the freeway while you're high. Let's not forget that not too many years ago, desegregation was illegal too.

We have kids who are smuggling knives and even guns onto school property - and these school administration schmucks have nothing better to do than try to stifle free speech by taking down banners across the street and arbitrarily suspending kids from school like criminals? Listen, Pal: mistrust authority -- it's a healthy approach.

Here's the thing: "Free Speech" means what it says. We either have free speech, and learn that the benefits of having it outweigh the negatives of what a few people may do with the right, or we don't have free speech at all. That's why both Liberal and Conservative groups support this kid's case.

Liberals mostly because the Far Left is against George Bush, the Patriot Act and just about anything that represents the establishment. But Conservative groups too because they see that if you can stifle "Mescaline for Moses" then you can shut down religious free speech too, and they don't like that one bit.

Shame on you bureaucratic bastards! Get your priorities straight. This is going to the Supreme Court now? Jeesh! What a waste of my tax dollars. However, the very fact that it was just heard by the Court tells me that we're really doing some national soul-searching here about our basic values. I just hope that free speech wins.

Um, hey! I'll take a toke of that... Now, what was I saying?

NOTE: Based on some comments, it appears that some people aren't fully aware of the facts surrounding this case. Wikipedia has a pretty good writeup, and it appears to me to be mostly unbiased.


MVP Summit Musings - 2007

Each year, Microsoft invites current MVPs (Most Valuable Professionals) to Seattle for their annual MVP Summit. MVP's get access to Product Group specialists and other dignitaries from Microsoft who share their visions of what Microsoft is doing and where they are going. Some of this information is "not to be disclosed", meaning that the MVP can find out about it but we aren't supposed to talk about it until the bits are released.

In sum, we get wined, dined, and seminar-ed to death.

This year, as I did last year, I had mixed feelings about the whole thing. Yes, I got to meet and talk with people who I respect such as Scott Guthrie ("Mr. ASP.NET") and Anders Hejlsberg, "up close and personal" which is always gratifying, as well as my MVP lead Rafael Munoz, who has been a fantastic resource for me as a .NET professional. Among other notables too numerous to detail, I also ran into Jason Alexander and Rob Howard, and we got a chance to chat about the OpenID .NET implementation that Jason is working on. If you haven't heard about OpenID, I predict that you will. It's basically SSO (Single Sign On) for dummies, and it does everything that Microsoft originally wanted with "Passport", except that it's already open-source and nobody is crying "world domination" like they did then. In fact, Microsoft has already formed an alliance with the OpenID gurus to lend its anti-phishing technology to the mix and provide support for CardSpace in OpenID.
(As a side note, I've already seen one blog comment that "OpenID sure beats Cardspace" -- heh -- OpenId and CardSpace are two different things. They are complimentary - but making that sort of claim instantly reveals that you are a Microsoft basher who has no earthly idea what you're talking about!)

On the other hand, I had to sit through some more or less "canned" sessions with presenters who, for lack of a better phrase, I'll characterize as "not completely up to the task". Fortunately, if you aren't happy with a session, there are usually 10 others going on at the same time, so you just get up and go somewhere else...

Those who have noticed, as I have, over the last couple of years, a sea change at Microsoft in terms of being more open to the developer community and more sensitive to the accusations of "Microsoft World Domination" syndrome should be gratified to know that Microsoft continues to open up to the rest of the world, making great strides in interop with their brethren in other companies as well as with the open source community.

The perennial "Microsoft Bashers" may continue to be deceitful and arrogant (not to mention plain ignorant!), but the fact of the matter is that MICROSOFT HAS CHANGED - and it continues to change. This should be self evident to even the most jaded Microsoft - basher when they see thet all of the source code for Microsoft ASP.NET AJAX has been made freely available by Microsoft to anyone with the inclination to download it.

A further example of this is the Iron Python (.NET) release which is true to the Python language and shows the dedication of the decision-makers at MS to support "non - Microsoft" technologies and languages and to be willing to spend money and man hours to put their money where their mouth is, dynamic languages being what i consider to be the next big frontier for .NET and the platform. The upcoming Oryx release, which plays well both with dynamic languages and LINQ, is another example.

New innovations with WPF/E (Windows Presentation Foundation in the browser), Oryx and LINQ, some of which I'm not allowed to talk about yet, are sure to blow your mind as a .NET developer in the next few months as new CTP releases and announcements come out, particularly at and after the MIX '07 conference in April.

And the great news is that ORCAS, the next big release of Visual Studio coming at the end of this year, has a huge number of innovations and improvements, and it will be the first version of Visual Studio to be able to target whatever Framework version you want -- just based on stuff you've got defined in your project configuration file.

But some things go backwards. I'm not a smoker, but I really enjoy a good cigar once in a while. Unfortunately, Seattle is basically a "no smoking" city. I mean, you can't even light up on the fyookin' STREET, unless you are 25+ feet away from the nearest door somewhere. So my good friends Bill Jones (MVP) and Robbe Morris (MVP) all had to go outside after our fabulous (and very expensive) Ruth's Chris farewell dinner to go find somewhere to light up and enjoy a decent smoke.

Aside from that, I'm happy to report that Microsoft as a whole seems to be moving in the right directions - opening up more and more to the developer community, putting out CTP releases on shorter build cycles (like 3 weeks to a month) and being much more interested in what you, the developer, have to say about all of it.

If I can help, don't be bashful. I'm always working to expand my contact list. I have some pretty good friends inside Microsoft, and I'm working to get a lot more as time goes on. You can find most of my "contributions" at either eggheadcafe.com or at the Microsoft C# Language or ASP.NET newsgroups.


IDisposable and Conservative Politics

There is a saying "You become a Conservative when you've got something to conserve".

In the programming world, it could be said that "You should only implement IDisposable when you've got something to Dispose". Here is an interesting Q/A interchange between a confused C# newsgroup poster, with some very good answers by Barry Kelly:

Q: "A discussion arose recently in a code review about whether or not one should implement IDisposible (and then call it) on an object which has neither unmanaged resources nor managed resources which are resource intensive (db connections, filestreams, etc.)."

A: If a class implements IDisposable, that tells me as a programmer that I *need* to call Dispose() when appropriate. If the class doesn't own other objects which implement IDisposable, and isn't likely to do so, then I would say - don't implement it.

But if you do implement it, implement it properly. Create a protected virtual void Dispose(bool disposing) method, and have your Dispose() implementation call Dispose(true). Then put all your logic in the protected virtual method. That way, descendants can extend the class properly.

Q: "It seems to me that if you do not have such items to explicitly dispose yourself, then it is best to let the Garbage Collector do its work when it determines it is the best time to clean up these objects."

A: Calling Dispose on an object whose class implements IDisposable does not cause it to be collected ahead of time. Dispose() is just a method call, like any other, a programming convention. There's no magic in the CLR relating to Dispose, the only magic is in C# and its 'using' construct - which is essentially a type-dependent macro.

Q: "But, my question is, does it matter? If I have SimpleObject, and I call simpleObject.Dispose() when I'm done with it, is there an associated performance liability over not calling the method?"

A: Possibly, it will cost more, because you're pointlessly calling a method. But the cost will be vanishingly small.

Q: Also, if I write an empty Dispose() method :
Is this object removed from the managed heap when I call that method?

A: No. Explicit deallocation is asymptotically more expensive than a copying / compacting GC like .NET's. That is, it would be more expensive if it did remove it.

Q: "Or is it actually cleaned up on Finalization, because it does not"

A: Only objects which implement finalizers are subject to finalization. And objects should only implement finalizers if they need finalization, that is, if they explicitly wrap an unmanaged resource. Typically this means they have a field of type IntPtr, or they descend from CriticalFinalizerObject, they call unmanaged methods via P/Invoke, etc.

If you aren't familiar, the Dispose pattern is defined by the IDisposable interface.

For classes that aren't sealed and need to do resource cleanup, you should follow the Dispose pattern, which has been designed to ensure reliable, predictable cleanup, to prevent temporary resource leaks, and to provide a standard, unambiguous pattern for disposable classes. It also aids derived classes to correctly release base class resources:

protected virtual void Dispose(bool disposing)
if (!disposed)
if (disposing)
// Dispose managed resources.

// If there are unmanaged resources to release,
// they need to be released here.
disposed = true;

// If it is available, make the call to the
// base class's Dispose(Boolean) method

Again, the bottom line: If your class doesn't have resources that it needs to dispose, you do not need to implement IDisposable. This will be the predominant case, so quit worrying about Dispose and go write some good code!