Thursday, April 12, 2007
Wouldn't it be nice if there was a way for your Windows application to store information on the local hard drive without having to worry about user access privileges? Well, with .NET 2.0, there is and the classes associated with it are IsolatedStorageFile and IsolatedStorageFileStream. Long story short is that use of these classes will allow your Windows app to cache information on the local hard drive specific to your assembly or application even if your user has the lowest of the low account privilege (i.e. restricted access like Limited or Guest).
In my code sample below, I'm going to use the above mentioned classes to perform the following actions for a console application (i.e. assembly):
- Store information on the hard drive specific to the user of the console application
- Retrieve that information for use at a later time
Here is the code you can use to do this:
// Be sure you add these two namespaces...
using System.IO;
using System.IO.IsolatedStorage;
...
// Write info to isolated storage based on the user and assembly...
IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForAssembly();
IsolatedStorageFileStream userStream = new IsolatedStorageFileStream("UserSettings.set",
FileMode.Create, userStore);
StreamWriter stream = new StreamWriter(userStream);
// Info you want to save...
stream.WriteLine("Saved Info: Whatever you want");
stream.Close();
...
// Read info from isolated storage...
string[] file = userStore.GetFileNames("UserSettings.set");
if (file.Length != 0)
{
userStream = new IsolatedStorageFileStream("UserSettings.set",
FileMode.Open, userStore);
StreamReader reader= new StreamReader(userStream);
string contents = reader.ReadToEnd();
// Write the info to the console...
Console.WriteLine(contents);
}
As you can see, this is a super simple and easy to use method for saving application info to the hard drive without having to worry about user access privileges.
Tuesday, November 21, 2006
So, this weekend I fired up my old Dell Inspiron 5100 and decided to give Vista a try. Overall, the installation experience went amazingly smooth, but I must be perfectly honest and admit that I didn't even attempt to go the upgrade route since my previous experiences with upgrading have always been problematic. To make a long story short, I gave the system a compete lobotomy by reformatting the drive and starting with a clean install of Vista Business Edition. By the way, a single Vista installation will actually support all four flavors of the OS (Ultimate, Home Premuim, Business, and Home Basic). It's appears that it's the access key that controls the feature set that is enabled on your particular system that seperates a Ultimate from say a Home Basic install. This allows you to be able to upgrade the OS by simply purchasing and inputing a new access key as opposed to having to re-install or upgrade the OS software again.
So, how's the experience...
Overall, the system is running extremely smooth and is performing well with just the basic installation of the OS itself. Haven't stressed it or messed around too deeply with it, but I think its working great coming straight out of the install with native device drivers only. Only bad news is that the Inspiron 5100 has such gimpy video, I didn't get to experience the beauty of the new Aero (i.e. also referred to as "glass") interface. With that being said, that is the only complaint I have about Vista. It really doesn't look all that great if you've got a whimpy video card like the 5100 has. Naturally, I'm anticipating that video performance will most likely improve once ATI releases a new driver for the Mobile Radeon 5400, but I'll have to wait and see (by the way, I'm not holding my breathe on that). I'm still getting used to the layout of the new Start menu, but that will improve over time. I'll be honest and admit that I had to change back to the Classic Start menu in order to perform a few Admin functions such as enable IIS and manage services, but, eventually, I'll figure out where these functions are in the new menu system.
As for other software, I also installed the following apps once the Vista installation was complete:
- Visual Studio 2005
- Visual SourceSafe 2005
- SQL Server 2005 Standard Edition
and they seem to be running fine as well. There were a few trivial incompatibilities that you have to manage; however, I do like the fact that Microsoft warns you about them upfront during the installation process so you can take care of them ASAP. Haven't installed any games, but I've heard some grumblings about performance and incompatibility issues. Then again, this is my home dev box so I don't plan on messing with games on it. Gaming is strictly for my Dell XPS that I'm not brave enough to upgade to Vista....yet...
Friday, November 17, 2006
Vista...RTM...
Yes, today is the big day if you happen to be a certifiable Microsoft geek with an MSDN account. If so, Vista RTM is just begging to be downloaded! I'll be updating my home development box tonight with the latest release and I'll keep you guys posted on how that journey goes...
Wednesday, November 15, 2006
If you're like me, there are times when you need some ambient music to keep the right brain happy when you're doing a lot of left brain intensive work like debugging, researching a problem, or cranking out code. In light of this, I thought I'd share one of my favorite internet radio sites that helps keep me going even during those inevitable late nights that plague us developer-types, http://www.di.fm/.
This site operates just like a radio station only it has a variety of music your wouldn't typically find on the airwaves, minus annoying DJs, and has minimal commercial interruption.
To use the site, be sure to scroll down the page to where you see the Radio Channels section. At that point, you'll start to see all the channels that they have to offer. Once you've found the type of music you want to listen to, click on either the 24k, 32k, or 96k button and it'll start streaming audio to your default player. Naturally, the higher value, the better the signal quality at the expense of more bandwidth usage.
My recommendations are Trance and Chillout, but there are plenty of options for you guys to choose from. If you're at work, just be sure the IT guys are cool with you sucking up some of there precious bandwidth...
I recently experienced some woes with updating a .dll in the Microsoft Download Cache, C:\Windows\Assembly\Download, that I've finally been able to resolve. Anyway, I thought I'd share my experiences to help any of you guys who might be encountering a similar issue. Here are some details to clarify...
Problem:
I had just completed some changes to a custom library, .dll file, that gets downloaded from our website to the client's download cache directory, C:\Windows\Assembly\Download, when I discovered that an older version of the file was continurously being loaded every time I tried to access the site as a client. This continued to occur despite the fact that I'd updated our website with the most recent revision of the file. In case you're curious, our website loads that .dll file onto the client so that it can communicate with the client's laser hand-scanner, a device used to read bar-coded information into controls of our site.
Root Cause:
An older version of the .dll file is continuously being loaded every time I access the appropriate page because the file has been cached to the client's local temporary internet files folder.
Solution:
Here are the steps that I used to effectively resolve this issue:
Please note: all these actions take place on the client which happens to be using IE 7
- Open Internet Explorer and click Tools -> Internet Options
- Under the General tab, click on the Delete button located in the Browsing History section
- Click the Delete files... button located under the Temporary Internet Files section
- Click Yes to delete all temporary Internet Explorer files
- Click Close
- Click on the Settings button located in the Browsing History section
- Click on the radio button that reads Every time I visit the webpage and make certain the disk space specified is greater than the file being loaded (you can change this back to it's original settings after the client has downloaded the new file if you aren't comfortable w/ this change)
- Click OK, click OK
This action will allow a new version of the .dll file to be loaded onto the client when he/she accesses your site.
Optional:
If you also wish to clear out the Download Cache directory, C:\Windows\Assembly\Download, on the client and start over fresh, you can perform the following actions:
- Open a Visual Studio .NET Command Prompt (can be either 2003 or 2005, but I just happen to be using 2005)
- It's located under Start -> All Programs -> Microsoft Visual Studio 2005 -> Visual Studio Tools -> Visual Studio 2005 Command Prompt on my system, but could be different for yours
- Type gacutil /cdl and hit the Enter key
This action will effectively delete all existing files currently located in the Download Cache directory.
Friday, November 10, 2006
Here is a rather useful control, the UpdatePanel control, that will allow you to perform a partial render of a web page after a postback is performed. So what does partial render do and why is it useful?
To answer those questions, I'll need to give you a brief description of how the typical postback process occurs:
- Client browser contacts Server via URL
- Server sends information about the construction of the entire web page to the client
- Client renders the web page on the user's screen
- User inputs information into textbox controls and clicks a button to initiate a postback event
- Client sends information to the Server for processing
- Server processes information
- Server sends back information about the construction of the entire web page
So what's the problem?
Well, after the user has clicked a button and initiated a postback event, the page is, essentially, frozen until the server sends back info to the client and the browser rebuilds/renders the web page. This means that any additional information that the user types into the web page will be wiped out once the page is rendered (that is, unless it is being trapped and rebuilt via Viewstate). Also, the screen will flash and the browser will reset back to the top of the page once the rendering process is complete (this can be remedied via SmartNavigation; however, that won't work if your client's browser isn't compatible).
Here is a perfect situation where partial rendering would be invaluable:
- You want the server to validate/process some user-supplied information while the user continues to enter more information on the page
- You don't want the user's new information to be wiped out once the server has completed processing of the data and provided status
- You want the postback to be as seamless as possible (i.e. no flickering or resetting the position of the web page)
In order to enable such functionality on your Atlas web page, you only need to add a few elements to an Atlas-enabled web page shown as follows:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
... Control that initiates Postback ...
... Controls that need to be modified after Postback finalizes ...
</ContentTemplate>
</asp:UpdatePanel>
</div>
The addition of this code between the appropriate asp controls located in the <Form> tag will now allow you to carry out asynchronous processing while the user continues to work with the web page. Essentially, the only information that will be sent back to the client after the server completes its processing will be the changes to the controls specified in the <UpdatePanel> tags (i.e. such as a label control that tells your user how the validation effort went). That's it! This, of course, gives the added bonus of using less network bandwidth on that last part of the client/server communication (the return of data back to the client after the server has processed its data) since you don't have to have the entire page rebuilt/rendered on the return trip. Pretty cool stuff, eh? Give it a shot and let me know if you need a sample to work with.
Welcome to the future of digital photography! If you've never seen a demo or even heard of Microsoft's new Photosynth application, an application the takes 3-dimensional imaging to an incredible new level, now's your chance to take the technology preview for a spin and see just how amazing this new technology is...
http://labs.live.com/photosynth/sysreq.htm?collection=sanmarco/index1.sxs
THE killer app all you obsessive/compulsive shutter-bugs have been longing for!
Friday, November 03, 2006
For the next couple of posts, I think I'm going to focus on showing off some of the new Atlas components; therefore, I'll go through a brief demo on how to start a new Atlas project using Visual Studio 2005 first before diving into them head first.
Before I begin, please note that Atlas is currently Beta and that means that things are going to be changing on a pretty consistant basis. I'd appreciate it if you can send feedback to me if something isn't quite lining up with what you're seeing so that I can update my posts appropriately.
With that being said, let's proceed with setting up that new Atlas project using Visual Studio 2005...
-
-
Open Visual Studio 2005
-
Click File -> New -> Web Site...
-
Since the new Atlas controls are contained under the CTP, you'll want to select the "ASP .NET AJAX CTP-Enabled Web Site" template under Visual Studio Installed Templates
-
Since I've got IIS enabled on my system, I'm going to select "HTTP" for location and type in "http://localhost/AtlasDemo" for the URL. You can select "File System" if you don't have IIS enabled on your system and choose a location where you want the files installed. If you choose "File System", Visual Studio can still emulate the web site for you when you run in debug mode (very nice feature by the way...)
-
Select your favorite programming language (I like C#) and then click the OK button

After a few seconds of Visual Studio chewing on your request, you'll have your first Atlas project set up and ready to go. Too easy, eh? Next post, I'm thinking we should check out the UpdatePanel component and see what it can do...
Wednesday, November 01, 2006
As I mentioned in my previous post, I've been playing around with Atlas, Microsoft's implementation of AJAX for ASP .NET 2.0, recently and think its about time I started sharing some of my experiences with you guys.
For starters, AJAX stands for Asynchronous Javascript and XML and it's a term that is used to encompass a variety of technologies whose overall mission is to provide us "web-head" types with a platform via which we can add more fluidity and functionality to our web pages through asynchronous operations. From what I've seen so far, the combination of these technologies allows client-server communications to go on behind the scenes in an extremely fluid manner making the typical static web page operate in a more dynamic fashion, dare I say, similar to what you'd find in a Windows application. To be perfectly honest with you, the technologies being used in AJAX really aren't ground breaking or new; however, the basic premise AJAX is to wrap these various technologies into a single architecture that makes it easier to for us developers to create, standardize, and re-use web components that would benefit greatly from asynchonous operations.
If you're one of those brave souls who like to work with Beta implementations, feel free to visit the following site that has everything you need to get started: http://ajax.asp.net/
To begin working with Atlas, you'll need the following items installed in the order given below:
-
Visual Studio 2005 or Visual Web Developer 2005
-
ASP.NET 2.0 AJAX 1.0 Beta
-
ASP.NET 2.0 AJAX CTP Beta
Naturally, the two AJAX installations can be obtained from the link I gave you above and, hopefully, you've already got Visual Studio 2005 already installed. If not, you might be able to get away with a Visual Studio Express Edition, but, unfortunately, I don't have confirmation on that. Anyway, give those installs a try so that you can work along with me as I experiment with this stuff. Next post, we'll start working with the basics and have some fun learning what this technology update can do...
Tuesday, October 31, 2006
Just wanted to say "Hi" and introduce myself as the latest DotNetNerd to join the fold. In case you're wondering who I am, I'm one of Steve's fellow Avanade cohorts who shares a common passion for developing software using Microsoft technologies. To make a long story short, that means that I'll spend a lot of time pushing their new stuff. Anyway, this technical blog is a big change for me because my usual forte is to blog about my exploits in the Colorado backcountry (skiing, hiking, rock climbing, etc) and not my about my journeys into the realm of cyberspace. So, what are my plans for blogging on this site?
Well, as of late, I've been messing around with Atlas (Microsoft's AJAX implementation), Windows Presentation Foundation, and SharePoint 2007 so I'll probably spend a lot of my blog-time sharing those experiences with you guys. Chances are good the topics will probably change as I decide to pursue interests in other technologies, but, for now, those are the most likely candidates.
Should be fun and we'll see where this goes!