August 2004 - Posts
Thought for the holidays: Two things that drive us, software development addicts: enthusiasm and laziness....
Just quoting Scott Hanselman
for this tip:
A day may come when you want to turn off the Debug dialog that appears when a .NET program has an unhandled exception.
Option 1: Registry key from Enabling JIT Debugging
For an application that includes managed code, the common language runtime will present a similar dialog to JIT-attach a debugger. The registry key that controls this option is called HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting.
- If value = 0, prompt the user by means of a message box. The choices are:
- Continue. This results in a stack dump and process termination.
- Attach a debugger. In this case, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none, control is returned, and the process is terminated.
- If value = 1, simply return control. This results in a stack dump, after which the process is terminated. (No more dialog)
- If value = 2, spawn the debugger listed in the DbgManagedDebugger registry key.
Option 2: If you want to disable the JIT debug dialog, but still want an error dialog:
Visual Studio.NET|Tools|Options|Debugging|Just-In-Time and deselect "Common Language Runtime" and now you’ll get an OK/Cancel dialog instead of the select a Debugger Dialog. Note: The registry entry from Option 1 above will need to be 0 for the dialog to show up.
Thanks to Eric Deslauriers of Corillian QA for these tips!
This dialog can be useful in some cases (mainly in development), but annoying in most cases. But, what if I want to disable this dialog per application?
Update: Given changes at webhost4life (new owner, new support, new control panel, new hosting environments) at the beginning of 2010, the review below is outdated. I now recommend Arvixe and OrcsWeb.
When I started SharpToolbox.com, I needed to select a hosting solution. I chose webhost4life, and this year I renewed my account with them because I think they have very goods hosting plans and I'm happy with them.
Here are a the main advantages you get with webhost4life:
- Price: I chose the $9.95/month plan (Update: now $11.95), and I consider it a bargain. (this means a one time payment of $140 for a year, one time setup fee included)
- Bandwidth: unlimited! Now, try to find something close from the other hosters for that price. And gigabytes fly by quickly... Unlimited bandwith is invaluable if you plan to share pictures, videos, or even software.
- Domains: you can create as many sub-domains as you wish for free, and host multiple domains on one account for $15 a year per additional domain
- SQL Server and MySQL databases
- ASP.NET 1.0, 1.1, 2.0
- Mail: POP and IMAP, SSL, SPAM protection, virus protection, 100 accounts by domain...
- Configuration: a control panel let's you setup your hosting
- They currently have a special offer that includes shared 128bit SSL and doubled space for the same price. For the $9.95 per month plan (Update: now $11.95), that means you get 300MB on disk + 300MB for SQL Server + 300MB for MySQL. Update: the new offer gives you from 1000MB to 3000MB of disk space and from 2000MB to 3000MB of SQL Server space!
Of course, you can see the details on their web site.
Everything is not perfect though, and I had to contact the tech support a couple of times to fix a few things. But the good news is that the tech support is efficient and fast enough. I've been happy with the free online tech support. My problems were fixed quickly.
I don't usually advertise for others, but here I have three reasons:
- people reading these weblogs may need a hosting solution,
- I'm satisfied with webhost4life and don't mind spreading the word to thank them for the service,
- I get a commision if you sign up with them and tell them madgeek sent you, or use this link to sign up :-)
Scott Mitchell created a WebControl named RoundedCorners. Its goal is to simplify the creation of rounded boxes in your dynamic web pages.
Let's quote Scott:
Creating a box with rounded corners isn't terribly difficult, and there's a myriad of ways for creating such design elements. Virtually all of the techniques, though, require using Photoshop or some other graphics editing program to create rounded corners of the appropriate color. For graphics designers, creating rounded corners must be extremely boring, and they likely hold as much interest in creating rounded corners as veteran ASP.NET developers do in creating a connection to a database. Been there, done that - thousands of times. But for non-graphics designers (like yours truly), creating these rounded corners can be frustratingly slow and annoying, especially if you're like me, and the only graphics editing program you have is Microsoft Paint.
To overcome this loathsome activity, I decided to create a custom ASP.NET server control that would utilize the dynamic image-creation capabilities of GDI+ to create the corner images for me. The result is an ASP.NET Web control, which I call RoundedCorners, that you can drop on an ASP.NET Web page, set a few properties, and be presented with a nifty box with rounded corners, as shown on the right.
The most up to date version of this control allows you to drag and drop controls into the control, just like with the standard Panel.
I recommand this control in case you want a simple rounded box. In cases where you want something more fancy and don't mind playing with a picture editor, you can use my old StyledPanel WebControl.
The source code is quite simple (one class, a few lines), and the control supports composition too, which means you can drag&drop controls from VS' ToolBox into the control.
Something you may want to do is upgrade this control to a templated one. This would let you specify separate content for the header of the control, and for the body, for example. Creating templated web controls is explained by Scott Mitchell himself.
How do you report spam? I use SpamCop
, and you, what is your preferred response to spam?
If you look at this post by SantoshZ of the C# team, you'll see code like this:
Connection conn = null;
conn = new Connection();
if (conn != null) conn.Close();
Well, this is quite a strange code snippet coming from the C# team, I must say! It demonstrates bad exception handling.
Here is what this code should look like in my opinion:
Connection conn = new Connection();
Why is that?
- There is no need to call Close() if Open() was not previously executed.
- There is no need to call Close() if Open() failed.
- You probably want "finally" instead of "catch"
Too often do I see code all in a big try...catch block.
BTW, don't forget to use the using statement, which greatly simplifies code in a lot of cases.
Watch Anders giving an informal talk in front of a whiteboard. He talks about C# features, present and to come. You'll learn what he thinks about AOP, dynamic languages, mixins, closures, iterators, nullables, and so on.
knows his thing. He was the one who gave the right explaination
for my quiz. I just copy it here:
DictionaryEntry is a structure and you're foreaching which means the instance is coming from IDictionaryEnumerator.Current therefore assigning to only the local copy. This would be a nasty problem if people forgot about the semantics of value types vs. ref. types, so the C# compiler prevents you from doing this.
However, I agree with Eric Newton
that the message from the compiler should be clearer! The current one is very confusing.
Now, if you want something even more confusing, you can try the following code: IDictionary dictionary = new Hashtable();
dictionary["dummy"] = "dumb";
IEnumerator enumerator = dictionary.GetEnumerator();
entry = (DictionaryEntry) enumerator.Current;
entry.Value = 0; // no compiler error, but "error" nonetheless
This one compiles, but doesn't do what you'd expect at first. Guess what the output will be... So yes, the compiler message is useful (even if not easy to understand), but doesn't fire in all the cases...
I would like to apologize to readers: you'll notice that posting comments on most of the posts of this weblog is currently disabled. You'll see "Comments on this post are closed" instead. I'm sorry about this, and I can't change anything about it right now :-( This is a new site-wide (weblogs.asp.net) setting.
I hope we'll be able to reactivate the comments soon! I don't like that setting at all. I appreciate comments much, and I do not consider that previous posts as obsolete. Scott, please do something!
I you want this feature to be disabled too, please say it
In the spirit of language quizes, you can try to find why the following code does not compile:
DictionaryEntry entry1 = new DictionaryEntry();
entry1.Value = 0; // OK
IDictionary dictionary = new Hashtable();
dictionary["dummy"] = "dumb";
foreach (DictionaryEntry entry2 in dictionary)
entry2.Value = 0; // NOT OK : "The left-hand side of an assignment must be a variable, property or indexer"
More Posts Next page »