Owner: Onion Peels URL:http://blueonionsoftware.com Join Date: Sat, 14 Apr 2007 13:33:26 -0500 Rating:0 Site Description: .NET, Technology, Life, Whatever Site statistics:Click here
NonContiguousMemoryStream Revised 2008-03-09 16:40:09 Earlier I wrote about a class I designed to combat large heap fragmentation issues with memory streams. I've updated the class to correct a bug I recently discovered in the read routine. I've also published the entire solution with additional unit tests. MemoryStreams are darn handy little buggers for caching away results from serialization and file copy operations. However, there's a dark side in that MemoryStreams can create additional memory pressure, particularly when stream sizes grow in excess of about 85K. At that point, the .NET runtime allocates from the large memory heap. This heap does not compact like the small memory heap and can lead to fragmentation. Often, this can cause OutOfMemoryExceptions long before physical memory is exhausted. No amount of garbage collection will r
A Solar Grand Plan 2008-03-07 08:01:51 Scientific American has a plan to wean us off oil and coal by using solar energy. It's an interesting read. Here are the key points. A massive switch from coal, oil, natural gas and nuclear power plants to solar power plants could supply 69 percent of the U.S.’s electricity and 35 percent of its total energy by 2050. A vast area of photovoltaic cells would have to be erected in the Southwest. Excess daytime energy would be stored as compressed air in underground caverns to be tapped during nighttime hours. Large solar concentrator power plants would be built as well. A new direct-current power transmission backbone would deliver solar electricity across the country. But $420 billion in subsidies from 2011 to 2050 would be required to fund the infrastructure and make i Read more:Solar
, Grand
Find your missing USB drive on Windows XP 2008-03-06 10:32:59 The How-To Geek as a great article on how to resolve removable drive
conflicts on your system. Have you ever plugged in a USB drive or any external device with a hard drive and wondered why you cannot see it in My Computer? More than likely the cause is that Windows
renamed the drive to a letter that is already in use. This will happen if you have several card readers, thumb drives or external hard drives attached. It will also happen if you are on a network and have mapped drives. Find your missing USB Drive on Windows XP I had this very same issue on my lap top. Nice step-wise procedure with lots of screen shots.
powered by Bloget™ - "One File, One
Binary, One Blog"
ESET NOD32 2008-03-05 08:21:02 I'm trying something a little different with the Web site. The new design is intentionally plain and focuses on content. I've also continue to remove advertisements as I learn what works and where. The goal of the ads is to generate enough revenue to pay for the hosting and a few software goodies like compilers and profilers. As I stated in my About page, Blue Onion Software is a personal project where I get to experiment and express myself. Google Adsense is an easy way to create revenue for a site. It does however have some problems in that you don't get to control what you advertise. For the most part, Google has good taste in the ads it selects for my site so I can't complain. I'm trying something new here by dipping a toe into affiliate advertising. Here, I can be a more selective.
Standalone Windows Live Writer Installer 2008-03-04 16:41:23 For some reason I can not get Windows
Live Writer
to install on my computer using the integrated Live installer. It just gives me some meaningless error message and dies. What I needed was a standalone installer that didn't require an Internet connection to execute. Well, after much searching, I found links to standalone installers for all the Windows Live programs. Here they are: Windows Live Mail Windows Live Writer
Windows Live Photo Gallery Windows Live Messenger Windows Live Sign-In Assistant Family Safety From Windows Live OneCare I should note that these links are not official. Someone has downloaded and copied all the installers from the temporary folder that the integrated installer builds and uploaded them to a shared location. You should scan these files for vir Read more:Installer
Testing with w.Bloggar 2008-03-04 14:16:47 Testing Bloget with w.Bloggar. Touted as "The best interface between you and your blog". It works great with Bloget
powered by Bloget™ - "One File, One
Binary, One Blog"
Read more:Testing
Make IE6/IE7 more usable with The World Browser 2008-03-04 12:43:57 As much as I like FireFox and Safari for Windows there are times when only Internet Explorer will do. This is often the case in corporations where you are either restricted to using IE or there are IT applications that will only run in IE. Personally, I find the IE6/IE7 interfaces annoying to use. Apparently I'm not the only one who feels this way. There are dozens of alternative browsers that use the IE rendering engine with enhanced interfaces.Most of these alternative IE browsers tend to be a bit too busy for my tastes. One notable exception is The World
Browser. It's lightweight and makes using IE noticably easier. The skin support allows you to change the look and feel. I particularly like the Safari skin, which is small, quiet and highly usable. Other features include intelligent adv
Microsoft: IE8 to support standards from the start 2008-03-03 19:03:06 Microsoft
has announced that its planned standards compatibility mode will the default. Earlier proposals required a special meta tag inserted into the Web page to force IE8 into the standards compatibility mode. Public out cry has apparently forced Microsoft to change its plans. More details can be found here.
powered by Bloget™ - "One File, One
Binary, One Blog"
Input Director - Control Multiple Computers 2008-03-13 08:36:25 As I write this I have 3 computers that I use for various purposes. I use to keep a separate keyboard and mouse for each one but I recently found a better way. Input Director
a let's you use one keyboard and mouse to control several computers. I've placed the screens side by side and then simply move my mouse from screen to screen. It's like one computer with 4 screens (I have two screens on my primary computer). A real time saver and it fits perfectly into my workflow. Input Director is a Windows application that lets you control multiple Windows systems using the keyboard/mouse attached to one computer. It is designed for folks who have two (or more) computers set up at home and find themselves regularly sliding from one system to the other (and wearing out the carpet in the process! Read more:Control
, Multiple
Katmouse - Scroll windows beneath the mouse cursor 2008-03-12 08:08:56 The best programs are the ones you install, forget about and use everyday. These programs integrate so well into the environment that they become part of your work flow. Katmouse is just such a program. Simply put, it allows you to scroll the window beneath the mouse cursor, even if the window does not have input focus. It's a simple behavior that it is instantly useful and requires no memorization to use. I wish there was more to say about it but that's really it. It just works and perhaps that's the best praise anyone can give a program. Highly recommended.
powered by Bloget™ - "One File, One
Binary, One Blog"
Read more:Scroll
NonContiguousMemoryStream 1.2 2008-03-16 15:45:26 I've updated my MemoryStream replacement that handles large streams with less memory fragmentation. You can read about it here. This version fixes a bug in the Seek method (specifically, SeekOrigin.End). I thought it should be illegal to seek past the end of a memory stream but apparently I'm wrong. The .NET MemoryStream allows this type of operation and so now does NonContiguousMemoryStream.
powered by Bloget™ - "One File, One
Binary, One Blog"
Number of Types in the .NET Framework 2008-03-17 11:15:38 Well, the answer is not 42. Try 11,417. Check out Brad Abrams blog for more statistics on the .NET library.
powered by Bloget™ - "One File, One
Binary, One Blog"
Read more:Number
, NET Framework
SimpleZip - Generate Zip files with one line of code 2008-03-22 09:19:21 .NET doesn't have much in the way of built-in archive support. If you want to Zip up some files
you can use the open source SharpZipLib or a commercial package like Xceed. There's also Zip API's in the J# library but you can't count on the assemblies being installed. A recent article in The Code Project called SimpleUnzipper inspired me to write a counter part aptly named SimpleZip. SimpleZip consists of one class with one public method and about 450 lines of code. It can easily be added to an existing project and the code is small enough that it can be readily understood and modified. The one static method is as follows: static void ZipTo(IEnumerable fileNames, Stream archiveStream) Its use should be self-explanatory. The archiveStream is of particular interest in that it doe
Console application debugging made easier 2008-03-27 10:09:36 When debugging console applications in .NET I like the program to pause just before exit so I can study the console output. One way to do this is to set a break point at the end of the application. This is OK but shifts the focus to the IDE which is annoying, especially in single screen environments like my laptop. I've found a better way. Place a finally block at the end of your program as follows. class Program
{
static void Main(string[] args)
{
try
{
// your code here...
}
finally
{
if (System.Diagnostics.Debugger.IsAttached)
{
Console
.WriteLine("Press [enter] to exit");
Console.ReadLine();
}
}
}
}
Now the program pauses while debugging allowin
Windows Vista SP1 - No Issues 2008-03-25 08:21:48 With all the negative press out there about WindowsVista
SP1, I would like to report that some of us have some how managed to install the service pack despite Microsoft's best efforts (yes, that was sarcasm). Really, it was a no brainer. Downloaded the bits last night (~450 MB) and ran the install. It took about 45 minutes and it was done. It was bit anticlimactic from what I was expecting given all the bad press. Geez, it couldn't even manage one lousy little plague of locus. And no my computer didn't slow down or my peripherals stop working or my head fall off. I don't know, maybe I'm just lucky but Vista has easily been the easiest and best operating system of the Windows series to date. Still, there are those here at the office that will swear on a stack of bibles that running Vista Read more:Issues
, Windows Vista
SimpleZip Update 2008-03-29 15:58:29 SimpleZip is my .NET (C#) Zip file generator that requires no third-party support libraries. You can read more about it at the Code Project. This update adds one additional API. void ZipTo(IEnumerable fileNames, Stream archiveStream, bool flatten); The new parameter flatten strips the directory paths off the file names when adding them to the Zip archive. This has the effect of "flattening" the structure to a single folder. Source code and sample project are available on the Downloads page.
powered by Bloget™ - "One File, One
Binary, One Blog"
Read more:Update
Unique April Fool's Prank 2008-04-01 08:59:01 You'll see a lot of April
Fools' Prank
s on the Web today. This unique spokeshave however, strikes me as a bit more clever than most. This tool is suppose to aid in making tapered dowels. Like most good April Fools' pranks, it's almost believable. Lee Valley is a purveyor of fine wood working tools and a place where I spend way to much money. It is also one of the best mail order businesses I have ever dealt with. The catalog is pretty to the point of being lustful (yeah, I'm a tool junkie). Great people and great products (no fooling!).
powered by Bloget™ - "One File, One
Binary, One Blog"
The Best Free Text Editor 2008-03-30 15:06:16 How many times have you've seen this title in a blog? There certainly are enough opinions out there and everyone has their favorites. So without further ado here's my choice - EmEditor
. This editor does the four things I demand in an editor. It opens very large files quickly Does not cutoff long lines Supports Unicode fully Scrolls quickly no matter line length or file size I have found very few text editors that can do all four things. For instance, the text editor in Visual Studio 2008 does not meet these requirements (it cuts off long lines). Others like NoteTab Plus and PS Pad come close but fail on one or more points. Of course EmEditor does much more like syntax highlighting, clickable URLs and regular expressions, but those are all nice to haves. The first job of
String.Format Tool in SilverLight 2008-04-03 11:54:24 Can't remember how to format a date in universal time using String
.Format()? How about scientific format for doubles? This little SilverLight tool helps you to quickly build a String.Format() call for any format-enabled type (int, double, DateTime, string) in .NET. Cool! And if you don't have or like SilverLight, there's a static page with the same information.
powered by Bloget™ - "One File, One
Binary, One Blog"
Events and Delegate Shortcuts in C# 2008-04-02 09:44:40 The syntax for events and delegates has always struck me as a bit bulky and hard to remember. For instance, to declare an Alarm event seen in many of the Microsoft code samples, you declare a handler type and an event of that handler type as follows: public delegate void AlarmEventHandler(object sender, AlarmEventArgs e);
public event AlarmEventHandler Alarm;
It's a bit wordy and there's a naming convention to remember as well. With .NET 2.0 however, the class library contains a generic delegate that makes declaring events a more intuitive.
[SerializableAttribute]
public delegate void EventHandler<TEventArgs>(
Object sender,
TEventArgs e
) where TEventArgs : EventArgs
Using the EventHandler generic delegate, the Alarm event can now be expressed in one line with a Read more:Shortcuts
Is "is" the forgotten C# keyword? 2008-04-05 07:14:21 When's the last time you've seen or used the "is" keyword in code? It can often be used instead of the "as" keyword. Here's an example from a Microsoft help file. // CanExecuteRoutedEventHandler that only returns true if
// the source is a control.
public void CanExecuteCustomCommand(object sender, CanExecuteRoutedEventArgs e)
{
Control target = e.Source as Control;
if(target != null)
{
e.CanExecute = true;
}
else
{
e.CanExecute = false;
}
}
The intent is plain enough. Return true only if the source routing the command is a Control. However, 10 lines of code (including white space) seems a bit excessive for so simple a test. The following one-liner does the same thing and it's easier to understand.
public void CanExecuteCustomCommand(o
Calling Managed Code from C++ Gotcha 2008-04-04 09:14:35 Here's an issue I ran into the other day. IMarkupServices markup = (IMarkupServices)htmlDocument2;
This line of code was imbedded in a C# routine. When called from other C# routines, it worked fine. However, when called from a legacy C++ program it raised an InvalidCastException.
The inner exception of this code reported a COM error of E_NOINTERFACE. Huh? Clearly the documentation says that IHTMLDocument2 contains a reference to IMarkupServices. So what's happening?
The Gotcha is that many COM (aka ActiveX) controls require single threaded apartment mode. In C#, you can force this by adding the STAThreadAttribute to your entry point as follows:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Ap Read more:Calling
Cheap GPS 2008-04-07 08:52:20 This really tickled my funny bone this morning. XKCD is one of my favorites. Always interesting. Warning: this comic occasionally contains strong language (which may be unsuitable for children), unusual humor (which may be unsuitable for adults), and advanced mathematics (which may be unsuitable for liberal-arts majors).
powered by Bloget™ - "One File, One
Binary, One Blog"
Read more:Cheap
, GPS
OS Smackdown: Linux vs. Mac OS X vs. Windows Vista vs. Windows XP 2008-04-08 12:27:58 There's an interesting comparison of operating systems by from Computer World as described by four experts in support of their desktop operating system of choice. It's an interesting read in that only one advocate has an unqualified endorsement. Here's an excerpt from Preston Gralla's view point. If you want the best operating system available today, there is only one choice: WindowsVista
. You heard me right: Vista, the operating system that people love to hate. The system that has been blamed, it seems, for everything from global warming to the U.S. economic meltdown. I'm here to tell you that the conventional wisdom is flat-out wrong. Vista is a solid, hard-working operating system that will run whatever software you need with simplicity and grace. And it doesn't suffer from t Read more:Smackdown
, Linux
, Windows Vista
Configuring the ASP.NET Health Monitor 2008-04-09 17:34:11 One of the things I really like about programming in .NET and ASP.NET is all the cool built-in functionality in the framework. The ASP.NET health monitor is an excellent example. ASP.NET health monitoring gives you an easy way to monitor the health of an ASP.NET application and to get detailed run-time information about ASP.NET resources (to instrument the application). Health
monitoring contains ready-to-use Web health-monitoring events classes (Web events) and health-monitoring providers (listeners). Web events package health-event information. ASP.NET health monitoring enables you to do the following tasks: Monitor
the performance of an application to make sure that it is healthy. Rapidly diagnose applications or systems that are failing. Appraise significant events during Read more:Configuring
New Resource Refactoring Tool for Visual Studio Released! 2008-04-11 13:06:12 After replacing about 100 strings with resource references recently, I began to wonder why Microsoft did not include a refactoring tool extract strings in code to resources. To do it currently requires switching back and forth between resource view and your code and copying strings. Tedious to say the least. Well, ponder no more. Microsoft has released a resource refactoring tool on CodePlex that does just that. Right-click, select Refactor and at the bottom of the menu you'll see a new entry labeled "Extract to Resource
". Features include: Works with C#, VB.Net languages. Supports all project types that ships with Visual
Studio 2005 including web sites and web application projects. A preview window to show changes. Finds other instances of the text being replaced in the
Vista Sidebar Stopwatch Gadget 2008-04-13 16:52:28 Vista has gadgets similar to what is found on the Mac and in Yahoo Widgets (formerly Konfabulator). For some reason, they have not been well received which (again) is a bit puzzling to me since they work quite well and are easy to author. The quality of a gadgets themselves is not always up to par with their Mac and Yahoo counterparts but that's not a limitation of the platform. My favorite gadgets are the NPR Listener, AdSense Monitor and Wireless Status Meter. Gadget
s are really easy to write. There's no compilation and the installation is as simple as placing the files in a special folder. To illustrate the point, I wrote a simple stopwatch gadget. The gadget is simplicity itself. Click to start, click to stop, double-click to reset. No buttons or countdowns or lap times. Nothing to c Read more:Vista
, Sidebar
Amazon Adds Service Health Dashboard 2008-04-17 10:18:20 I use Amazon
's S3 service to serve images for this Web site. It's a great service, especially for high volume site (don't I wish) because it scales automatically. It's also a pay as you go service meaning you only pay for what you use. Amazon now has a Dashboard
that shows the current and historical status of these services. Rumor has it that Amazon will make more money selling these services than from their mainline merchandise business within a couple years.
powered by Bloget™ - "One File, One
Binary, One Blog"
Read more:Service
, Health
Stopwatch Gadget on Windows Live 2008-04-17 08:44:34 I posted my little Stopwatch Gadget
on Windows
Live the other day. The response has been interesting. The early adopters gave me high marks averaging 4 and 5 stars. Now that John Q Public has started chiming in the scores have dropped dramatically. My only guess is that they see the gadget as so simple as to not be worthy of a good score. From my perspective, the gadget is useful because of what it doesn't do. It doesn't make me think. I can click anywhere on the gadget to start and stop it. I don't have to carefully aim my mouse to hit the right button because there is no button. It's an easy mark to hit. That's the software developer's dilemma I suppose. We're forever having to one-up the other guy to get attention. Sure, I could add lap timers, and skins, and flyouts and graphical im Read more:Windows Live
I'm on Twitter 2008-04-16 12:15:52 Everywhere I read, Twitter
is a must for bloggers. So I'm giving into the dark side and setting up shop on Twitter. You can follow my tweaks or twips or whatever they're called at If I'm an idiot for doing this then I must also be a twittyidiot! Whatever...
powered by Bloget™ - "One File, One
Binary, One Blog"