|
|
These blog entries are written by industry experts and leaders. We consider this content to be a good read for any software developer or web technologist.
December 2006 - Posts
-
A couple people asked me how my WPF/E port of Life turned out.
Answer: it works pretty well. Here is the source code if you want to look. I built the project with an .aspx page, although I don't use any server side logic and the page could easily be plain HTML. The XAML is not fancy Expression built XAML. In fact, the board is mostly built inside script. There is just enough XAML to bootstrap the board.
<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height = "300"
Width = "300"
x:Name="gameBoard"
Loaded="BLOCKED SCRIPTgameBoardLoaded">
</Canvas>
I'm looking forward to future releases. 
|
-
I've been tagged by Paul, so here are 5 things to share about me: 1) I was born in Michigan, lived for two years in California, and then spent a decade growing up in England. I attended Duke University and graduated with a degree in Computer Science. 2) During college I also worked for Apple Computer. 3) I joined Microsoft straight out of school. I was recruited by 5 different teams within Microsoft that were each trying to sell me on their group. J Allard (who then ran the IIS team and later went on to create the XBOX and Zune) found out I'm a huge college basketball fan and somehow got Bill Gates to send me a basketball to help convince me to join his team: Although the basketball wasn't actually the reason I picked the team, it didn't hurt. ;-) 4) I am a General Manager within the Microsoft Developer Division and manage the development teams that build several Microsoft products/technologies including: the CLR, .NET Compact Framework, ASP.NET, Windows Forms, WPF and WPF/E, IIS, Commerce Server, and the Visual Studio tool support for Web and WPF applications. Although my blog is heavy on ASP.NET content, that is actually only one of the technologies I spend time on. 5) I write all of the blog posts and samples on my blog myself. A lot of people often ask if I have help doing them - but I actually write all of the posts/tutorials entirely myself (hence the reason I usually post between 10pm and 2am at night <g>). I've posted 217 blog posts over the last 12 months and have responded to ~6500 (non-spam) blog comments this year. It has kept me busy, but I also find it a lot of fun. Have a great New Year's celebration - see you in 2007! Scott 
|
-
The Moth tagged me, so now you'll find out more than you wanted to know about me.
1. I scream like a 7 year old girl when I see a cicada bug.
In 2004, Brood X cicadas overran the eastern United States. Three days a week, I had to get in and out of an office building surrounded by swarms of cicadas. At first, I was curious about the bugs. Curiosity turned to terror. After one week, I lost all traces of rationality. I started to think the bugs were carnivorous space aliens who wanted to crawl inside my ear and eat my internal organs. The security guard at the building once wanted to call for an ambulance to pick me up. The guard though I was having a cardiac arrest - I was only trying to shake a cicada off my shoulder.
2. My crab cakes are the best ever!
In school I needed to make money for, um, books - that's it, so I had some formal training in the kitchen and logged quite a few hours as a line cook in a steak house. I still love cooking. One of my specialties is crab cakes.
Scott's Crab Cakes Recipe
1 lb. Backfin crabmeat 1 large egg A touch (~ 1 tsp) of Worcestershire sauce A touch (~ 1 tsp) of dry mustard A heavy touch (to taste) of Old Bay seasoning
I combine all the ingredients in a bowl and gently mix with my fingers. I then shape the mix into 6 firm cakes. Cooking without filler and breadcrumbs can be tricky, but to me those ingredients ruin the taste of crab. If the cakes are firm enough, and the pan (with very little butter) is just the right temperature, I can make nice, brown crab cakes in about 10 minutes, and without the cakes falling apart.
3. I almost went to school to be a musician instead of an engineer.
Not an uncommon occurrence in the software world, it seems. I still play the trumpet and flügelhorn in the occasional community theater production. I wish I had the time to practice more often and keep my chops up enough to play a tune like Maynard's Chameleon. RIP, Maynard - we miss you.
4. The K stands for Kenneth.
My parents named me after an uncle who passed away before I knew him, but they wanted me to be called by my middle name of Scott.
5. Retirement Plans
I'm thinking of one day retiring in Goa. I might open a small jazz club with a dining area. Maybe I'll call it Ken's.
Now I have to tag 5 others to see if they'll play in this meme and tell us 5 things we don't know about them. In no particular order:
Phil Haack
Rick Strahl
Anil John
Sahil Malik
Milan Negovan

|
-
I've been tagged by Brendon, so here are 5 things that you don't know about me: - While I was born in Mobile (AL), and went to school there from 3rd grade until I graduated high school, I actually started school in Italy.
- I was 3rd place in 4th grade 50 yard dash -- the 1st and 2nd place finishers went on to be my high school running back and quarterback.
- My high school chess team won 3 Mobile county and 3 Alabama state championships -- we had no star, but were all equally pretty good.
- I was goofing around on a piano and singing when I first met my wife Jenny -- then we went to a Chinese group at the University of Alabama.
- I started programming professionally when I was laid off from teaching college math during a budget crisis that laid off everyone not tenured.
And now I return the favor and tag Jerry Dennany, Paul Lockwood, Greg Young, Kirk Evans, and Scott Guthrie.

|
-
I sat down to look at WPF/E this evening. WPF/E is Microsoft's cross-platform XAML engine that runs in a web browser. The technology is currently in a community preview stage.
I thought a good first step would be to port my "Game of Life" WPF application to WPF/E and see the game run in a browser. A quick look at the documentation revealed that WPF/E doesn't support data binding, resources, or layout controls (like the Grid).
A good contrast will be to compare the following snippet of WPF code to my hacked up WPF/E equivalent. This C# code dynamically creates a "life" indicator in each cell of a grid control.
Ellipse ellipse = new Ellipse();
Grid.SetColumn(ellipse, column);
Grid.SetRow(ellipse, row);
ellipse.DataContext = _cells[row, column];
mainGrid.Children.Add(ellipse);
ellipse.Style = Resources["lifeStyle"] as Style;
With no data binding, no resources, and no Grid control, the JavaScript code for WPF/E has to take an alternate route.
var xaml = '<Ellipse Height="7" Width="7" />';
var ellipse = this.agControl.createFromXaml(xaml);
ellipse.Fill = this.CreateBrush();
ellipse.Opacity = this.cells.isCellAlive(i,j) ? 1 : 0;
gameBoard.children.add(ellipse);
ellipse["Canvas.Top"] = (this.agControl.height / this.size) * i;
ellipse["Canvas.Left"] = (this.agControl.width / this.size) * j;
WPF/E has some clever solutions to tough problems. There is no Ellipse constructor function as you might expect. That approach would require a massive JavaScript file with functions defined for all the WPF/E objects. Instead, we create objects graphs using XAML fragments. The code merely needs to pass these fragments to the WPF/E ActiveX control's createFromXaml method and receive an object in return. Also, notice the syntax for attached properties in WPF/E (ellipse["Canvas.Left"]).
If I had $100 to spend on WPF/E features, I'd spend the whole lot on adding data binding and layout controls. Overall, WPF/E is a bit different from what I expected before I started this evening. At this stage, the technology is good for performing animations, and playing media. No small feat, really, but anything the team can add that will facilitate day-to-day business requirements (build a dashboard of key performance indicators, fill out an insurance claim form) would make the technology terrific.

|
-
Google has deprecated their SOAP Search API in favor of an AJAX Search API. This move provoked a great deal of discussion.
Some say the move was purely technical - Google is leaving its angled bracket XML partner to move in with the younger, sexier JSON. Others say the move was a business decision - Google can't afford to let advertising opportunities slip by.
I think Google did solve a technical problem. The problem was unregulated XML data. The solution was an AJAX control. Control is the essential word. The scripts that Google requires for the new search API keep them in control of the search results, the branding, and the advertisements. Producing data from an XML web service doesn't afford this level of control, but producing behavior through a ubiquitous scripting language does.
This could be the first of many backlashes against the bohemian goal of creating free-for-all mashups. Companies with balance sheets and stockholders aren't looking for a technology that will give them data interoperability, but a technology that will protect their investments.
AJAX is the DRM technology for the Web 2.0.

|
-
I've been catching up on JavaScript basics recently.
Here is a simple example to demonstrate the difference between the event target (where an event takes place), and the this reference (where an event handler is defined).
Consider the following hunk of HTML:
<div id="List">
<ul>
<li> One </li>
<li> Two </li>
<li> Three </li>
</ul>
</div>
We could write an event handler like so:
<script type="text/javascript">
window.onload = function()
{
List.onclick = List_onclick;
}
function List_onclick(e)
{
var evt = e || window.event;
var evtTarget = evt.target || evt.srcElement;
alert(evtTarget.nodeName);
alert(this.nodeName);
}
</script>
Clicking on one of the list items will reveal that evtTarget references an LI element, while this references the DIV element. I like this style, but for various reasons we often wire event handlers like so:
<div id="List" onclick="return List_onclick()">
<ul>
<li>One </li>
<li>Two </li>
<li>Three </li>
</ul>
</div>
And the script, which doesn't change a great deal:
<script type="text/javascript" >
function List_onclick(e)
{
var evt = e || window.event;
var evtTarget = evt.target || evt.srcElement;
alert(evtTarget.nodeName);
alert(this.nodeName);
return false;
}
</script>
Clicking in a list item will show us that the evtTarget is still an LI element, but this.nodeName will now show as undefined. The function List_onclick in the second example is part of the global object, which doesn't have a nodeName.
I always have to think about what this will reference in JavaScript, which is one reason the language makes me queasy.

|
-
Every now and then I like to give myself a fun little programming challenge. I'll randomly pick some enjoyable task, like programming a game or blogging engine or what not, and impose a time limit, anywhere from an hour to an afternoon. Such little challenges keep the fun in programming and help me mentally recharge. After spending a week of programming boring data entry forms, such toy projects help remind me why I enjoy computer science and programming!
Anyway, a few months ago I decided to see if I couldn't create a simple online Blackjack game that would allow a single person to come to the site, enter their name and starting bank role, and play Blackjack against a dealer. If you're interested in checking out this little toy application, the result of an afternoon of enjoyable coding, you can download the complete source code from here. There's also a light 4Guys article that provides some light details on the code, Creating a Quick and Dirty Online Blackjack Game.
If you decide to download and poke through this application, please do bear in mind that it was purposefully rushed, as I was racing against the clock to complete the project. Consequently, the code may be rather tattered in places, there are likely many spots where it should be refactored, and there are next to no comments. Let's just say that it's not a showcase of 'best practices', unless you're MacGyver and need to program a blackjack game in under four hours or a nuclear missle is going to explode.
See the Blackjack Wikipedia entry for rules and basic strategy.

|
-
Scenario: You finish building a great ASP.NET application, have everything tested and working right on your local system, are taking full advantage of the new ASP.NET 2.0 Membership, Role and Profile features, and are ready to publish it to a remote hosting environment and share it with the world. Copying the .aspx files and compiled assemblies to the remote system is pretty easy (just FTP or copy them up). The challenge that confronts a lot of developers, though, is how to setup and recreate the database contents - both schema and data - on the remote hosted site. Unfortunately there hasn't historically been a super-easy way to accomplish this. The good news is that this week the SQL Server team published the release candidate of a new SQL Server Hosting Toolkit that will make it much, much easier to deploy your SQL solutions remotely to a hosted environment. The toolkit allows you to work with SQL Express, SQL Server 2000, and SQL Server 2005 databases locally, and then easily transfer your schema and data and install them into a shared hosting remote SQL Server account. The below post describes how you can start using this today. SQL Server Hosting Toolkit The SQL Server Hosting toolkit is available for free, and ships with a Database Publishing Wizard that supports two database hosting deployment scenarios: 1) The Database Publishing Wizard enables you to point at a database you are working with on your local system, and then automatically create a .SQL script file that contains the setup logic needed to re-create an exact replica of the database on any remote system. This .SQL script includes everything needed to create the database schema (tables, views, sprocs, triggers, full-text catalogs, roles, rules, etc - full details here), as well as populate the new database with the same table row contents as your local database (this is analogous to the MySQL dump utility). The benefit of having this setup logic encapsulated in a single .SQL file is that most hosters already support the ability for you to upload .SQL files to their hosted environments and run these scripts via their hosting admin control panels. Assuming you have a web hoster that supports this today, you can immediately start using the Database Publishing Wizard to easily deploy your sites without requiring anything to be installed or configured by the hoster. 2) The Database Publishing Wizard also enables you to point at a database you are working with on your local system, and then use web-services to transfer and recreate the database in your remote hoster environment (without you having to create the .SQL file or use the hoster admin control panel to run it). This publishing option does require that a SQL Publishing web-service be exposed in the hosting environment, and the SQL Server Hosting Toolkit includes a free implementation of this SQL Publishing web-service that we'll be working with hosters to aggressively deploy. The Database Publishing Wizard enables you to use either SQL Express or SQL Server 2000/2005 locally, and then use either SQL 2000 or SQL 2005 in the remote hoster environment. It does not require that the versions of SQL match - so you can use SQL Express 2005 locally and then upload to a SQL 2000 server in the hosting environment without having to change any of your code. The Database Publishing Wizard also supports handling the built-in ASP.NET 2.0 Membership, Role Management, Profile and Health Monitoring schemas. A lot of people have run into issues because the built-in .SQL scripts that ship by default with ASP.NET for setting up these schemas require DBO permissions at install-time for the SQL scripts -- which a lot of hosters don't support (note: the scripts do not require DBO permissions at runtime - only for install time, but this can sometimes still be a blocker in itself unless the hoster is willing to install them for you). The Database Publishing Wizard on the other-hand does not require DBO permissions when installing the ASP.NET Membership, Roles and Profile schemas/data, and should enable you to deploy the ASPNETDB tables + sprocs just as easily as any other database using the Database Publishing Wizard. First Tutorial: Deploying a SQL Express Database to a SQL Server Hosting Account (using .SQL files) I'll be doing a series of posts over the next few weeks showing how to use the various features within the SQL Server Hosting Toolkit. This first tutorial in the series covers how to use it to easily generate a .SQL installation file of a local SQL Express database that you can then copy to a remote hosting account and use to re-create a SQL Server database for you to use with your hosted site. Step 0: Download and Install the Database Publishing Wizard The first step we'll need to-do is to make sure we have the Database Publishing Wizard from the SQL Hosting Toolkit installed. Click here to download it and install it. The Database Publishing Wizard comes with support for both a GUI based wizard, as well as a command-line utility. The GUI based wizard can be run either standalone or via context-menu support that it adds to the Server Explorer in both Visual Studio 2005 and Visual Web Developer Express. For the purposes of this tutorial we'll be using this later Server Explorer integration - which makes publishing really easy. Step 1: Create an ASP.NET web-site that uses a local SQL Express or SQL Server database To help with this demo, we will use the built-in Personal Starter Kit template that ships with both VS 2005 and Visual Web Developer Express. To create a new web project based on it, select File->New Web Site within VWD or VS and choose the "Personal Starter Kit" template in the New Web-Site dialog. By default the personal starter kit application is configured to use SQL Express (which is free and can be downloaded here). When run the sample looks like below: After creating the application, you can then run the web admin tool (choose the WebSite->ASP.NET Configuration menu item in VWD/VS) and create a new user and add them to the "admin" role for the site. You can then login as this new admin user and try uploading new pictures and/or customizing the existing ones on the site (note that both the picture meta-data, as well as the raw image binaries are stored in a database when you do this): Once you are all done with the above steps we'll have two SQL Express databases installed within the \app_data directory for our project. One of the SQL Express databases is named personal.mdf and contains the tables and stored procedures specific to our web-site (photo and album tables, as well as basic content management support). The other SQL Express database is named aspnetdb.mdf and contains the database storage for the default ASP.NET 2.0 Membership, Role and Profile providers (which the application above is using for login and admin purposes). Step 2: Creating .SQL Installation Scripts for our Database Now that we've created a new application + local database, and added custom data to it (new users + their role membership, as well as new photos and albums), we want to deploy the application to a remote hosting server. The first step we'll take is to create .SQL script files that will enable us to automate re-creating the exact same database schema + database content on our remote hosting account. To-do this we'll use the Database Publishing Wizard we installed as part of the SQL Hosting Toolkit. To begin, click on the "Server Explorer" tab within Visual Studio or Visual Web Developer to see the databases that the application is using: As you can see in the above picture, we have two SQL Express databases that we are using: ASPNETDB.MDF and Personal.MDF. To generate .SQL installation files for each one, simply select the database in the solution explorer, then right-click and select the new "Publish to Provider" context menu item (added by the Database Publishing Wizard) setup on it: This will launch the Database Publishing Wizard and allow us to walkthrough scripting the installation of our database. As I mentioned in the intro of this blog post, the Database Publishing Wizard supports two deployment options: 1) To generate .SQL install script files that you can copy to your remote hoster and run using their existing web admin control panel tools, or 2) To upload the database directly using Database Publishing Web-Services on the hoster web-site. For this first tutorial, we'll be using the .SQL script file approach - so keep the default radio button selected and provide a name for the .SQL install script file you want to generate: When you click "next" you'll be given the option to customize some of preferences when creating the .SQL setup file. Note that you can control whether to drop existing objects within the target database, whether you want to target SQL 2000 or SQL 2005 with the script, and whether you want to setup both the schema and data, or just the schema, or just the data: For this tutorial just keep the defaults selected, and hit next and generate the .SQL script: You now have a Personal .SQL file that contains a script that you can run on any SQL server to re-create all the tables, sprocs, views, triggers, full-text catalogs, etc. for a database, as well as import and add all of the table row data that was in the database at the time the .SQL file was created. The .SQL file itself is just plain text - so you can open it up with any text editor to see it and/or customize it with your own statements: Notice above how the .SQL file includes both the SQL DDL needed to create the Photos table (including all of its constraints and primary-key/foreign-key relationships), as well as the SQL to insert data within the table once it is created (in the case above it is even inserting binary data for the photos - since they are stored in the database). Once you repeat these steps for the ASPNETDB SQL Express database as well you'll have two .SQL installation scripts that you can use to automatically re-create your SQL database on any SQL Server: Note that the .SQL files we built can be used to create two separate databases on a server, or they can both be run against the same database to create a single database that has a unified set of tables, sprocs, and data for the application. To accomplish this, simply run both scripts against the same database, and assuming no table or sproc names conflict, you'll have a single database containing everything. This later option is very useful when you have a hosting account that only provides 1 database instance for you to use! Step 3: Using our .SQL files to create our remote databases Now that we have our .SQL files, we can go about using them to install our database at our hoster. Exactly how we use the .SQL files to install the database will vary depending on how the hoster gives us access to our SQL account. Some hosters provide an HTML based file-upload tool that allows you to provide a .SQL file - which they will then execute against the SQL database you own. Other hosters provide an online query tool (like below) that allows you to copy/paste SQL statements to run against your database. If you have a hoster which provides an online query tool like this, then you can open the .SQL file with a text-editor and copy/paste the contents into the query textbox and run it. The quality of the SQL tools that different hosters provide varies quite a bit. In testing the Database Publishing Wizard we found that some custom-made SQL admin tools provided by hosters had issues where they incorrectly parsed valid SQL statements (in particular GOTO statements). This page describes one issue you might see some hosters have with GOTO statements, along with a workaround you can use. To help improve the overall quality of SQL hosting admin tools, the SQL Server team early next year is going to be shipping the source to a free SQL HTML admin tool that hosters will be able to integrate into their experiences. Hopefully this will help improve the standard experience with all Windows hosters. If your hoster has no usable HTML web admin tool for allowing you to easily manage your SQL database, then you can also just write a simple ASP.NET page that you FTP (along with your .SQL file) to your web-site and then hit to read the .SQL file on the server in as text, and then pass it as a string to ADO.NET to execute. This will give you the same result as the query analyzer above - and fully create your database for you. Step 4: Updating our connection-string within web.config Once we've got our data uploaded within a database at our hoster, we'll want to upload our .aspx files, assemblies and content to the remote site (typically this is done over FTP). The last step we'll need to take is to open up our web.config file and update the <connectionStrings> section to point at our new database location at the remote hoster. Note that you'll need to get the exact SQL server, database name, and username/password account to use from the hoster. Using our personal starter kit example above, we'd change the <connectionStrings> section within its web.config file from the default connection-string (which uses two SQL Express database in the local \app_data directory): <connectionStrings> <add name="Personal" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Personal.mdf" /> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" /> </connectionStrings> To instead use a single SQL Server 2000 database (the "scottguDB" database on the "Server123" box). <connectionStrings> <add name="Personal" connectionString="Data Source=Server123;Initial Catalog=scottguDB;Integrated Security=True" providerName="System.Data.SqlClient" /> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="Data Source=Server123;Initial Catalog=scottguDB;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> We were able to use a single database (instead of the two above) because we we ran both .SQL files against the single database - which merged all schema and data into a single database instance. Step 5: We are done Now we can run the application remotely in a hosted environment, and it should just work. Summary The Database Publishing Wizard that ships as part of the SQL Hosting Toolkit should make creating .SQL files for any database (SQL Express or full SQL Server) really easy. You can use this to easily dump your local database and then use it to re-create the exact same database on a remote system. In future tutorials I'll also show how you can actually re-create your database remotely without even having to generate a .SQL file (instead you can publish the database directly from VS to your hoster over a web-service). Stay tuned for details on how to-do this soon. Hope this helps, Scott P.S. We are planning on adding the Database Publishing Wizard into Visual Studio "Orcas" (which is the next release of VS), which means you won't need to download it separately in that timeframe. But we wanted to make sure you didn't have to wait until then, which is why we are making it available today for Visual Studio 2005 and Visual Web Developer Express 2005. P.P.S. Please visit this page to find other ASP.NET Tips, Tricks and Recipes I've written on other topics in the past. 
|
-
It was a quiet December evening. In the distance, a chime rang. Suddenly, an Outlook Reminders window appeared on my desktop.
This is an actual picture of the window as it appeared at the time. The window would not resize. The window would not maximize. I made torturing gestures with my mouse, but the window held my reminders as closely guarded secrets.
I poked around with the registry editor and found a value named WindowPos under HKCU\Software\Microsoft\Office\11.0\Options\Reminders. Deleting this value and restarting Outlook made the Reminders window appear with a normal, visible size. Problem solved ...
... except, I couldn't remember what I was working on before my reminders appeared.

|
-
One of the questions I'm often asked is whether it is possible to run an ASP.NET web-site project as a top-level root "/" site using the built-in VS web-server and the VS 2005 Web Site Project model. By default, when you open a web-site as a file-system based web site project and run it, VS will launch and run the built-in web-server using a virtual app path that equals the project's root directory name. For example: if you have a project named "Foo", it will launch and run in the built-in web-server as http://localhost:1234/Foo/ What a lot of people want to-do instead is to just run the web-site as http://localhost:1234/ or (if port 80 isn't already in use): http://localhost/ Doing this can make site navigation and url handling logic much simpler in your code. Prior to VS 2005 SP1 being released, I would recommend either running the project using IIS instead (here is a past post of mine on using the web-site project model with IIS), or to use a blog of mine from a year ago that discusses how to use the "external tools" feature in VS to enable root web-sites to accomplish this. The good news is that VS 2005 SP1 makes this even easier with the built-in VS web-server. Step by Step Instructions on Configuring a VS 2005 Web Site Project to Run as a Root "/" Site The below steps walkthrough how to configure a VS 2005 Web-Site Project to run as a root "/" web-site: 1) Open up an existing web-site project or create a new one by selecting the File->New Website menu item. 2) Using the solution explorer within Visual Studio, select the web-site project node: 3) Go to the property-grid within the IDE, which (if the project root node is selected) will now display the project properties for the web-site. There are three relevant properties that we care about for the purposes of this tutorial: "Virtual path", "User dynamic port", and "Port Number". Change the "virtual path" setting to / to run as a root web-site. You can also then set the dynamic port setting to "false" and configure a specific port to use (for example: port 8081 or port 80 if it isn't already in use): 4) Now click on a page within the project and run it. You will see that the web-server was launched as a root "/" site: Note that the :8081 was added at the end of http://localhost because I already have IIS7 running on my Vista machine and it has a site using port 80. If I disabled IIS I could have configured the web-site project to use port 80, in which case the web-browser would just have http://localhost/ in the address bar. I can now perform root-relative navigation within my sitemap (example: /products, /help, etc), as well as in my redirect logic and with standard HTML elements (example: <a href="http://weblogs.asp.net/path">). I can also now reference javascript files relative from the root, for example: <script src="http://weblogs.asp.net/js/library1.js"></script>. Tips/Tricks for Handling CSS StyleSheets with VS 2005 and ASP.NET 2.0 One of the techniques I recommend taking advantage of with ASP.NET 2.0 when using CSS is to use the Master Page feature to provide a consistent UI across your site, and to reference all stylesheets in one place using a master page (all pages based on the master will then automatically pick them up). One tip to take advantage of is the relative path fix-up support provided by the <head runat="server"> control. You can use this within Master Pages to easily reference a .CSS stylesheet that is re-used across the entire project (regardless of whether the project is root referenced or a sub-application): <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>
<html> <head runat="server"> <title>Master Page</title> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" runat="server"> <asp:contentplaceholder id="MainContent" runat="server"> </asp:contentplaceholder> </form> </body> </html> The path fix-up feature of the <head> control will then take the relative .CSS stylesheet path and correctly output the absolute path to the stylesheet at runtime regardless of whether it is a root referenced web-site or part of a sub-application. The pages within your web-site can then look like the content below and automatically pick up the stylesheet settings (both at runtime at a design-time within the VS HTML WYSIWYG Designer): <%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Sample Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<h1>Root Web Site Sample</h1> <a href="/Products">Click here to go to the Products section (note the absolute path) </a>
</asp:Content> Because image references contained within a .CSS stylesheet are referenced by a browser relative to the path of the .CSS file (and not actually the path of the page the stylesheet is being used on), you can combine this behavior with the <head runat="server"> logic above to have your images automatically work both with root web-sites and sub-applications (and not break if you change paths later). Images referenced this way will also show up fine within the VS 2005 HTML WYSIWYG designer (which can otherwise sometimes have trouble determining the root "/" path to pick up image references). Hope this helps, Scott P.S. The Web Application Project Model within VS 2005 also has full support for root "/" web projects and the VS web-server (WAP projects by default are root relative). To configure the path settings using a web application project, right-click on the web project node in the solution explorer, select "properties", and then click the "web" tab to configure them. P.P.S. Click here to read more of my ASP.NET 2.0 Tips, Tricks and Gotcha posts. 
|
-
I find the Sidebar gadgets in Windows Vista appealing. I never thought this would happen. I've looked at desktop widget technologies like Konfabulator before, but I've always felt like I'm looking at a traveling carnival.
Traveling carnivals transform a grassy field of rural America into a noisy assortment of amusement rides, games, and food stalls. The bright colored lights attract people to the midway hawkers, who in turn entice the crowd with prizes at games of chance and skill. The magic of a carnival eventually wears off when you realize the food isn't that great, the games are rigged, and rides are one spin away from creating a newspaper headline.
Likewise, the irregular windows and glossy colors of most gadgets are inviting. It's not till they've been hanging around awhile that the novelty wears off and you start to wonder if they are providing any value. How many distractions do I need eating up CPU-time and RAM?
The turning point came for me when I thought about how easy it is to create a gadget, and how pervasive the Vista sidebar will presumably become. This opens the possibilities for highly specialized gadgets that have staying power. In the software development world, I'm thinking of gadgets to monitor build status, work item counts, and bugs.
I've been experimenting with gadget development in the evenings, and I can say they are fun to work with (JavaScript notwithstanding). I hope to have an article posted here soon.
In the meantime, here are some interesting resources I've found.
WPF Vista Gadgets - Part 1: Using XBAP and IFRAME
Gadgets: Write Once, Run Everywhere
Vista: Sidebar Gadgets The Outlook Gadgets Are Here
Introducing IIS Stats v1.0 for Windows Sidebar
Vista Sidebar Gadget for Cruise Control.NET

|
-
VS 2005 SP1 shipped on the web last week. One of the overall goals with VS 2005 SP1 was to improve IDE performance and responsiveness for a number of common scenarios (a few examples: build times, managing large projects, refactoring, and intellisense). For web-scenarios, we specifically worked on the performance of the HTML source editor - especially with cases involving large HTML documents or slower machines. Below are a few specific changes we made in SP1 to improve performance in this area: 1) We tuned the performance of the HTML Validation feature (to learn more about this feature read this old post of mine). Validation of large documents now happens faster, and will not impact typing or updates as much (whereas previously validation would sometimes cause a slight stutter if you were typing in HTML source editing mode while the document was still in the process of validating). 2) We fixed a scenario where if you turn off HTML validation, and then work on a page that has a bad HTML validation error, and then switch into WYSIWYG design mode, validation is automatically turned back on for you to help you identify the error. While useful for debugging the error, a lot of people found this feature annoying since it meant that validation was continually being re-enabled without them realizing it (and on slow machines or with large documents this could slow down perf). Now when you turn off validation, it will stay off. If there is a blocking issue when you try to switch into WYSIWYG design mode, we will still identify the error for you, but we won't reenable validation for everything. 3) We added an option to optionally turn off using the property grid in HTML source editing mode. In our performance profile samples we found that keeping the property grid updated with the correct HTML schema as you cursor throughout a document ended up taking a non-trivial amount of CPU time, and in talking with customers we found that a lot of people weren't taking advantage of this feature anyway (note: supporting the property grid in HTML source mode for server controls was a new feature with VS 2005 that didn't exist in VS 2003). If you aren't using the feature, or are on a slow machine, then I'd recommend keeping this feature disabled. Important Note If You Want Property Grid Support in HTML Source Editing Mode As I mentioned above, with VS 2005 SP1 we now have the ability to configure whether the property grid is used or not while in HTML source editing mode. Because the majority of developers we talked with weren't using this feature (most were not actually even aware that it existed <g>), we decided to make the default configuration with SP1 to have this feature disabled. This means that when you are working in HTML source editing mode by default with SP1 you'll now see a property grid that looks like this: If you want to re-enable the property grid in source mode so that it is dynamically updated as you cursor through the document, simply open the Tools->Options menu item and click the "Enable Property Grid in Source View" configuration option within the Text Editor->Html->Miscellaneous category: You will then have the property grid re-enabled just like in the VS 2005 RTM release: Please note that this setting has no impact on the property grid in HTML WYSIWYG design mode or on any other designer - the property grid is always enabled/displayed in those scenarios. It only impacts HTML source editing mode (which we think is a much more rare scenario). Hope this helps, Scott 
|
-
In case you missed it, Microsoft shipped XNA Game Studio Express 1.0 last week. XNA provides a rich .NET based framework for building games, and supports development using C# and Visual Studio. The games you build with it can then be run on both Windows clients, and XBOX 360 consoles. XNA relies on a version of the .NET Compact Framework CLR that we ported to run on PowerPC chips (the XBOX 360 ships with a 3-core PowerPC CPU). For a killer demo that will impress your friends, install XNA Express, load up the built-in "SpaceWar" C# starter kit template, customize it, deploy it to the XBOX 360, run it and dazzle them with the graphics, and then set a breakpoint within your C# code in Visual Studio and show hitting the breakpoint and stepping through it in a live debug session against the XBOX 360 as you are playing the game. Pretty cool. You can download XNA for free, and learn more about it on the MSDN XNA web-site. Included on the MSDN XNA site are a number of nice Channel9 videos that you can watch here to quickly get up to speed on the project. I also found the www.xnadevelopment.com site very useful (it contains a number of good step-by-step getting started tutorials - like this one). If you are looking to have some fun this holiday season, try writing a cool game using .NET. Hope this helps, Scott 
|
-
My Working with Data in ASP.NET 2.0 tutorial series looks at building a layered architecture and demonstrates working with data against that architecture. The tutorials implement the architecture as classes in the website's App_Code folder. Ideally, these layers would be implemented as separate Class Library Projects in order to aid with development, deployment, reusability, and code maintenance. But we chose to use the App_Code approach to lessen the learning curve and to make the articles more accessible (you cannot create Class Library projects in Visual Web Developer).
Anywho, a common question I've received over the months is, “Just how do I implement the architecture as separate Class Library projects?“ Part of the challenge is that implementing the DAL as a separate Class Library places the connection string settings in the project's Properties settings instead of reading them from the website's Web.config file.
I've been tinkering with the idea of using Camtasia to create demos / instructional material / additional content for the written word. It's been on my to-do list for several months, but today I decided to sink in 30 minutes and try my hand at it. In any event, what follows is my first attempt, and not surprisingly, it is pretty low quality. As such, I'm wondering what settings folks who create professional-looking demos using Camtasia use to make it look nicer. I recorded at about 900x800 pixels and had it converted into an AVI using the highest sound and video quality. Granted, the resulting AVI that Camtasia produced was very crisp. It was in uploading the video to Google Video that ended up causing the blurry output. And my microphone is nothing fancy.
So, in short, the following video is a fine example of getting what you pay for. Hope this helps someone! Any feedback on whether it's worth it to persue learning more about this medium to improve the quality of the presentation? Or should I stick to the written word?
|
-
I have been pretty slammed lately. We have been working hard getting our project into production, there have been some rough spots but we are starting to look pretty good. This is the project I have been working on for the last year and a half. When we started .NET 2.0 was still in beta, and now a service pack for Visual Studio 2005 is coming out. I realized the other day that I have blogged very little about this project, but I plan on changing that and talking about what we have been doing, the challenges we have run into, and some of the interesting solutions we have come up with.
In my “off-time” I have been busy wrapping up the book, working on the book website, and working on another side-project I will just call csoft for now. The book is off to the printers, the site is going pretty well, and I am very excited about csoft. The interesting thing with csoft is that I already have a couple of non-programming partners, including a PM who is working on all the logistics and a salesman who is already laying the groundwork for getting sales going. I have started and given up on plenty of projects in the last couple years, but this time around with others helping push me along things are going much better.
I have also been taking some more time to enjoy life. I am reading more (I have about 5 more book to post about). Catching the Titans games every Sunday with my sister and brother-in-law, and spending some time working on the house.
-James

|
-
Yesterday I blogged about VS 2005 Service Pack 1 (SP1) being released. If you have previously installed the VS 2005 SP1 Beta, then you need to uninstall it before installing the final SP1 release. With Windows XP you can do this by going to your Add/Remove Programs list in the control panel, where both Visual Studio and the SP1 Beta Patch will show up in the list. Several people over the last day have asked me about how this works on Windows Vista - since a quick glance at your Add/Remove programs won't show up the SP1 Beta Patch. The reason for this is because Vista separates "updates"/"patches" separately from installed programs. You need to click the "View installed updates" link on the top left of the programs and features control panel to see these: Once clicked it will list all patches/updates on your system: You can then select the SP1 Beta patch and uninstall it. In addition to the VS 2005 SP1 download, yesterday we released a beta for a download that fixes Vista specific issues with VS 2005 (we are waiting a few more weeks to get user feedback on using VS 2005 on Vista to find any remaining issues before we declare this second Vista update done - but you'll be able to install this VS 2005 for Vista beta patch now to get immediate fixes). For some reason the download link to this VS 2005 for Vista patch isn't working at the moment (probably due to the massive storm we had here in the Pacific Northwest that has left most of the area without power or Internet access). I have mail off to the VS servicing team to get an updated link, and will post it here once it is live. Hope this helps, Scott 
|
-
Visual Studio shipped the final release of VS 2005 SP1 yesterday. It is available for immediate download in all 10 languages (English, French, Spanish, German, Italian, Japanese, Korean, Russian, and both traditional and simplified Chinese). You can download and install it here. This SP release is a pretty major service pack, and incorporates a lot of bug-fixes and feedback from customers. Included built-in with the service pack is support for VS 2005 Web Application Projects (which we also made available as a separate download back in May). It also contains a number of design-time performance optimizations and fixes across the product. Some Suggestions on Installing the Service Pack The service pack itself is a fairly large download (431Mb), and can take 30-90 minutes to update your Visual Studio 2005 installation depending on which versions of VS you have installed, and what features are enabled. So you should plan ahead and not expect it to be a few second operation (note: it is a good task to kick off before lunch or in the evening). A few suggestions/comments on the setup process: 1) Before starting the SP1 upgrade make sure you first uninstall the standalone VS 2005 Web Application Project download if you've installed that on your system. You'll no longer need this as support for it is built-in to SP1, and the SP1 installer will block and make you uninstall it if you have it installed. Your existing web application project files will continue to work just fine - so you won't need to-do anything to update them to work with SP1. 2) SP1 will run the upgrade patching process on each copy of Visual Studio 2005 it finds on your system. So if you have VS 2005 Professional, Visual Web Developer Express, and Visual Basic Express on your system, it will run the patching process 3 times (since each of these installs have separate copies of some files). If you aren't using all of these versions on your system, you might want to uninstall some of them - both to save yourself some disk space as well as to speed up the SP1 install process. 3) SP1 will patch/update all files/features in VS 2005 that you have installed. Sometimes I just click "install everything" when I setup VS 2005, in which case I get a lot of features that I often don't use (for example: some of the C++ header/lib sources for ATL, MFC, etc). What I've seen on my personal system is that when I only have the features I use installed, the SP1 upgrade process takes about 15 minutes end to end. But with everything it can take closer to 45-50 minutes. You might want to consider unchecking certain features of VS if you aren't using them and want to both save some disk space as well as speed up the SP1 install process. One last built performance suggestion SP1 does include a number of build performance improvements (for both VB and C#). For suggestions on how to optimize Web Site and Web Project build performance with VS 2005, I also highly recommend you check out my optimizing build performance blog post here. This will help you optimize your build times significantly for both RTM and SP1 systems. Hope this helps, Scott P.S. Some people have noticed that my pictures and sample downloads on my site are missing at the moment. Unfortunately the Puget Sound region was hit by a really bad storm last night, and all electrical power was knocked out in the area shortly before 1am (exactly 3 minutes after I finished my ASP.NET AJAX RC post last night - I hit submit just in time <g>). Both my house and the Microsoft campus are without power at the moment, which means the server hosting my pictures/downloads is not running. They are hoping to get us power again in the next few days, at which time my server will (fingers crossed) come back up. Until then I'm hanging out in a very crowded Starbucks for heat/light and will also be sporadic on email. Sorry in advance for any delays. 
|
-
If you haven't heard it already, VS 2005 Service Pack 1 is out and can be downloaded here. It contains over 2200 bug fixes according to Scott Guthrie, as well as making Web Application Projects standard once again. Also according to Scott, the install time can vary significantly depending on what you have installed, and is especially very long if you have C++ installed. My own experience was that it took about an hour to install on my system, although that actually involved what I can only describe as two 1/2 hour installs. Yes, maybe it was a fluke due to something on my system, but it installed once and said it was done, and then kept going with another install, including the exact same couple of dialogs, before finally asking to reboot. Maybe your experience will be different, but in the end I suppose what matters the most is that our VS 2005 experience will now be improved every day. 
| |
|