The readonly keyword differs from the const keyword.
A const field can only be initialized at the declaration of the field.
A readonly field can be initialized either at the declaration or in a constructor.
Therefore, readonly fields can have different values depending on the constructor used.
Also, although a const field is a compile-time constant, the readonly field can be used for run-time constants, as in this line:public static readonly uint l1 = (uint)DateTime.Now.Ticks;
Thursday, December 18, 2008
The Difference between "const" and "readonly" in C#
Thursday, October 30, 2008
SubWeaver: a Subversion plugin for Dreamweaver!
SourceForge.net: SubWeaver
The cool thing about it is that it integrates with TortoiseSVN (at least mine did), so that part of the interface feels very familiar!
Way to go, guys!
Wednesday, October 8, 2008
WPF: Getting at information entered in Assembly Information dialog
WPF: Getting at information entered in Assembly Information dialog
anything you enter inside Assemblyinformation dialog sits in the AssemblyInfo.csYou can access these values using Assembly.GetExecutingAssembly.GetCustomAttributes(true/false);If you print the types of attributes returned, you can see something like shown below.System.Windows.ThemeInfoAttributeSystem.Diagnostics.DebuggableAttributeSystem.Runtime.CompilerServices.CompilationRelaxationsAttributeSystem.Runtime.InteropServices.ComVisibleAttributeSystem.Reflection.AssemblyFileVersionAttributeSystem.Runtime.CompilerServices.RuntimeCompatibilityAttributeSystem.Reflection.AssemblyTitleAttributeSystem.Reflection.AssemblyDescriptionAttributeSystem.Reflection.AssemblyConfigurationAttributeSystem.Reflection.AssemblyCompanyAttributeSystem.Reflection.AssemblyProductAttributeSystem.Reflection.AssemblyCopyrightAttributeSystem.Reflection.AssemblyTrademarkAttributeSo if you want to access the Description entered in the Assembly, you can do something like this.foreach (object o in Assembly.GetExecutingAssembly().GetCustomAttributes(true)){if (o is AssemblyDescriptionAttribute) Debug.WriteLine((o as AssemblyDescriptionAttribute).Description);}That is just an example.Hope this helps.
Worked great for me!
Thursday, September 4, 2008
Echominder is even cooler than I thought!
Not only does echominder call you when you want it to, it also keeps a queue of your reminders on the website, and you can re-remind yourself by telling it to send you a particular message at a specific time (again).
Previously I was under the impression that the messaging was just a one-time event. Turns out I was wrong (and can't read documentation)! Awesome!
Kaxaml - Great Lightweight XAML Editor
Kaxaml
...and it's great! It's really nice to be able to try out the default snippets that are in the tool, and then to be able to grab XAML code blocks off the web and try them out on-the-fly without having to create a Visual Studio 2008 project - which is just too time consuming to try stuff out.
A very nice, and in my opinion, agile development tool!
Thursday, August 28, 2008
CLI - The next new old interface paradigm:
Introducing Ubiquity
...which seems to be based on work done by the same guys who did Enso (in fact Aza Raskin is on both demo videos):
Humanized - Enso
...but transformed from an OS utility into a browser mashup utility. I'm sure it's not for everyone, but it could make life simpler for some folks.
Thursday, July 17, 2008
WinForm Tip: Setting Opacity on Panel Control
I'd really like to have genuine opacity in my panels and other controls (a la WPF), but this will work OK for now:
drawing Opacity For Panel Control
Monday, May 19, 2008
How to Create a Transparent User Control in .NET
Thankfully there was a post from Zhi-Xin Ye of Microsoft on the MSDN Windows Forms Forums, in which he outlines how to "roll yer own" transparent UserControl:
Transparent User Control
Wednesday, May 7, 2008
echominder: a home run from Intuit (and it's free!)
One of the coolest services that has come out of their research group is Echominder:
echominder
Here's a description from the echominder site of how the service works:
scenarioI had actually been using a similar system before signing up for echominder: I'd call my voice mail at work to remind me to do certain things, but I would have to actually be in the office and then log into my voice mail to get the message.
you've got a flight tomorrow and just remembered you need to pick up your dry cleaning and set your out of office message. you're driving to work and can't stop to write it down, but echominder is in your speed dial:
- as you're driving home, call echominder and instruct it to have your cell phone ring at 4:30pm with a reminder to pick-up the dry cleaning.
- leave another message to call you at 8:00am tomorrow morning to remind you to turn on your out of office message on your computer before you shut down and leave for the airport.
- your phone rings right on time and you get the important things done.
Now that I've used echominder a few times, I've found it to be invaluable since it takes out the variables that caused my older methodology to break down:
- Location: I don't have to be in the office, because echominder calls me wherever I am.
- Timing: echominder calls me at the time I specify; I don't have to get a message and then remember to act on it at a particular time, or enter it into Outlook to remind me.
Friday, May 2, 2008
Visual Studio .NET Tip: Setting Tab Order
Thankfully there is a pretty slick way to do it, and I never would have guessed that it was there, but sure enough there was an MSDN Magazine "Advanced Basics" article on the subject back in 2002:
Advanced Basics: Visual Studio .NET: Setting Tab Order, Loading the Toolbox with an Add-in
Thankfully, they didn't change it. It's still there, and here's the procedure:
To set the tab order, you simply select [the controls on which you wish to change the tab order], then select Tab Order from the View menu. Then just click the controls in the order you want the tabs to sit. As you click each control, the tab order will be displayed on the control to keep you up to date. Press Esc when you're finished.
The good news is that this feature is still present in Visual Studio 2008 for Windows Forms, but I'm not sure about the WPF editor, though... hopefully it's still present.
Kudos to Matthew MacDonald for "Pro .NET 2.0 Windows Forms and Custom Controls in C#" book!

This book has already paid for itself in just a couple of weeks -- due to the time saved in trying to find the information I need. Every time I have a question regarding an issue in Windows Forms or with Custom & User Controls, I can find it here. Additionally, the content is written in a manner that can be understood by mere mortals, with some good tips and tricks thrown in too.
Highly recommended.
On the merits of this text, I've already purchased Matthew MacDonald's WPF book (the 3.0 one, since I haven't *quite* moved to VS 2008 yet...).
Thursday, May 1, 2008
XBAP First Glance...
ActiveX Document Redux?
I had read about them in the context of ClickOnce deployment, which may ultimately be a great way to deploy desktop apps through the browser, but XBAP is a relative newcomer. I say relative, because, as Scott Hanselman points out, this smells a lot like ActiveX Documents, with the exception that XBAPs do run in Firefox (but not on FF Mac/Linux unless the Mono guys can crack that nut).
Turning The Pages 2.0: a Live XBAP Example
Anyway, I was really impressed by an amazing example of an XBAP in the application created by the British Library:
Turning The Pages 2.0
http://www.bl.uk/ttp2/ttp1.html
Just this morning I was zooming in on a hand-written copy of Jane Austen's "History of England" (which she wrote when she was 13!), and the experience was a little surreal, as was viewing and turning the pages of Leonardo Da Vinci's Codex Arundel. It felt a little like turning the pages of the books in Myst game series, except these are real books.
Please note that this is not Silverlight (formerly known as WPF/E), this is an actual, full-blown .NET WPF application running in your browser, and the system requirements are commensurate with those technologies.
It's certainly worth checking out, but I'm a little skeptical that this is the next big thing in application deployment (just try clicking the back button in your browser when running the application). The requirements may be a little heavy too, but it definitely opens up some new doors, and machines will hopefully keep up with the demands of these new flavors of applications (WPF, XBPAP, etc.).
Additional References:
Monday, April 28, 2008
Remember to set SynchronizingObject property for System.Timers.Timer objects in .NET WinForms
I'm currently building a cool animated window, and instead of using the drag-n-drop timer for WinForms I wanted to just use a timer in code (in this case System.Timers.Timer), since I need it to go into a couple of modes, and it just seemed more straightforward since all my code related to the timer could be just in my .cs file, and not spread across the .Designer.cs and the .cs files.
When I tried to set a property on the form from the event handler I had set up that responded to the Timer's Elapsed event, I was getting a nasty "Control control name accessed from a thread other than the thread it was created on" error.
After scanning the help documentation (see the MSDN Help Link), it turns out that when using a timer with a form, it's advisable to set the SynchronizingObject property to the form object to prevent the aforementioned threading error:
If you use the Timer with a user interface element, such as a form or control, assign the form or control that contains the Timer to the SynchronizingObject property, so that the event is marshaled to the user interface thread.
The good news is that after setting the SynchronizingObject to the form object, the threading issues went away and the form started to behave correctly!
Tuesday, April 22, 2008
Extract Superclass Refactoring on UserControl
- How do you perform an "Extract Superclass" on an existing UserControl in .NET?
I then posted this question on the MSDN Forums.
Honestly, I was hoping that there would be a tool for doing this, or at least a documented process. No such luck.
So, I went ahead and did my best to perform the refactoring, all the while documenting the procedure.
To summarize, here are the steps:
As promised, here's an oversimplified list of the things I did to accomplish this:
Created a new UserControl to use as the base (let's just call it "BaseUserControl"). Moved private member variables, event handlers, and other methods pertinent to the functionality I wanted up into BaseUserControl. Copied control(s) I needed from OriginalUserControl into the BaseUserControl using the visual designer (it's just easier that way, plus resources are managed correctly). Hooked up BaseUserControl events to the event handlers using the visual designer (again, it was just easier). Commented out duplicate code in OriginalUserControl (i.e. the methods, etc. that were moved up) Changed the inheritance of OriginalUserControl from UserControl to BaseUserControl. Build, fix, build......and it worked! Now I can build a NewUserControl based on BaseUserControl and it will have all the functionality that I was wanting in the container, but I can still add more controls, etc. specific to each case I need it.
I just wanted to mention again why I wanted to do this in the first place, since it may seem weird to go through all this:
- First, I created a pretty useful control for a project I was working on, but didn't think about reuse (oops!).
- Naturally, it became apparent that I would need another similar component after the initial proof-of-concept was done.
- After determining that the functionality of the container could be used in other controls, I needed a way to pull that functionality up so that I could use inheritance to create new user controls based on the container.
Actually it wasn't as bad as I thought, though it sure would be nice if this was an automated process, or at least if there was a documented step-by-step how to on the subject.
At any rate, I sincerely hope this helps other developers faced with a similar challenge!
Eclipse Process Framework
In this podcast, he talks about an interesting tool, the Eclipse Process Framework, and it sounds like a really interesting tool for customizing software development processes:
The Eclipse Process Framework (EPF) aims at producing a customizable software process enginering framework, with exemplary process content and tools, supporting a broad variety of project types and development styles.
I'm not sure if this is something I would use, but one thing is certain:
- no one process works for all organizations.
All groups are different, and some have legacy processes that they prefer or use.
So the notion of being able to pick and choose process components to fit your situation and organization is pretty compelling.
Plus, it's all free and available as an Eclipse plug-in, which is pretty cool too.
Tuesday, April 15, 2008
Visual Studio Wish List: Default to Code View in Windows Forms?
I'm working in the code most of the time, and am in the visual designer just a very small percentage of the time, so why can't I set the default to just open the code window?
Crazy.
Hopefully this has been fixed in Visual Studio .NET 2008, but I'm not keeping my hopes up. Alternatively, perhaps this option will be available in the WPF form designer, which would be an improvement - and I can see myself moving in that direction.
Wednesday, March 12, 2008
New Beginnings...
Thanks go to William Stone of IntraNotions, Inc. (no relation. pure coincidence.) for getting this idea planted in my brain, and thanks to my wife for getting enthused about helping out with the business end of things!