|
|
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.
June 2007 - Posts
-
It's common behavior in the technology arena to hold on and wait for the next big thing. Sometimes we wait for bug fixes. Sometimes we wait for new features. It's not just software – I've waited for phones and TVs because I know the next generation will be so much better.
Have you ever picked up a piece of hardware or software and said, "this is perfect - I can't imagine anyone ever making this better?"
If so - how long did that feeling last?

|
-
I've been thinking about getting a MySpace page, but first I need a good design.
What do y'all think of this?
Define: Web 2.0. It's about me, me, and me.

|
-
Three Windows Mobile developers, Mort, Elvis, and Einstein, are sitting at the lunch table when their project manager bursts into the room.
PM: "Guys, I have some good news and some bad news."
Mort: "Tell us the good news first!"
Elvis: "Wait! I need to grab my laptop and take copious notes."
Einstein: "I have a theory about what you are going to tell us."
PM: "Be quiet and listen. The good news is that we bought iPhones for all the software developers".
Mort: "iPhones? But the product only targets Smartphones!"
Elvis: "Cool! Where is the SDK?"
Einstein: "You should've waited for an updated iPhone that includes GPS!"
PM: "The bad news is your iPhone is also your severance package. We've just moved all product development work overseas."

|
-
One of my first evaluated public speaking events was a disaster.
In high school, my teacher filled a basket with index cards. Each card had a "topic" printed on it. One by one, we had to go to the front of the room and pick a random card from the basket. We then had 60 seconds to prepare a 5-minute presentation on the topic we selected.
When it was my turn, I went to the front of the room and picked out a card. I looked, and my card said, "Break on through to the other side". I put the card in my pocket.
An abbreviated version of the next 60 seconds inside my head went something like this:
What does he expect from this? A motivational speech? I can't give a motivational speech! What are we suppose to break through? School? What's on the other side of school? This is terrible. I don't know what to talk about. I should say I'm going to the bathroom and pull the fire alarm.
Wait - this is a Door's song. Jack likes the Doors. I remember seeing another song called "Peace Frog". What a strange name for a song. "Peace Frog". Frogs eat flies.
Is my fly open? No.
If my fly was open in front of class, Melanie Weigel would be laughing and telling the whole school. She's such a drama queen. One day I'm going to fill her locker with shaving cream – just to see the scene she creates.
Flys.
Frogs.
Frogs are green.
Kermit the frog is green.
I loved the Muppet show. Especially those two old guys sitting in the balcony, razzing on everyone. I wonder if the show is ..."
Ding!
With no escape in sight, I put on my bravest face and stood behind a little podium at the front of class. Having completely forgotten my original topic, I proceeded to ramble for 5 minutes about characters on the Muppet show. You can't go wrong talking about Muppets. Everyone loves Muppets!
I could tell by my teacher's expression he wasn't loving Muppets. He asked me what was printed on my card. When I pulled out my card and announced my topic, there was about 10 seconds of dead silence. Everyone was trying to figure out how I went from "Break on through to the other side" to a television show about hand puppets named Miss Piggy and Dr. Bunson Honeydew.
Grade: 2/10.
I've worked really hard over the years to get better, and stay on topic.

|
-
I decided to try out Twitter, you can find me here. Oh yeah, you can find me on Facebook as well over here. And linkedin over here. Add me to google talk (jamesavery AT gmail) too if you use it (I am trying to move off MSN). When is someone going to make a social network for social networks to hang out on? -James 
|
-
I am done with the project I have been working on for almost 2 years now. To say we had challenges on the project would be an understatement, if you made it Day of .NET or the Dayton User Group you might have seen my presentation where I fill an hour and a half with all of the different problems we had. I am going to turn that presentation into a series of blog posts, hopefully starting with one this weekend. Yesterday was a fitting end to the project, after leaving the client for the last time I high-tailed it up to Columbus to see Wolfmother with Dave Donaldson (the man who recommended me and brought me onto this project). I really feel quite liberated now that I don't have a job and I am moving to Raleigh in about a week. I think over the past two years I haven't blogged about alot of things because I was worried about people at the client reading it (more on that later) but now that I am gone I feel I can really start blogging again. -James 
|
-
Last month I started a blog post series covering LINQ to SQL. LINQ to SQL is a built-in O/RM (object relational mapping) framework that ships in the .NET Framework 3.5 release, and which enables you to easily model relational databases using .NET classes. You can then use LINQ expressions to query the database with them, as well as update/insert/delete data from it. Below are the first two parts of my LINQ to SQL series: In today's blog post I'll be going into more detail on how to use the data model we created in the Part 2 post, and show how to use it to query data within an ASP.NET project. Northwind Database Modeled using LINQ to SQL In Part 2 of this series I walked through how to create a LINQ to SQL class model using the LINQ to SQL designer that is built-into VS 2008. Below is the class model that we created for the Northwind sample database: Retrieving Products Once we have defined our data model classes above, we can easily query and retrieve data from our database. LINQ to SQL enables you to do this by writing LINQ syntax queries against the NorthwindDataContext class that we created using the LINQ to SQL designer above. For example, to retrieve and iterate over a sequence of Product objects I could write code like below: In the query above I have used a "where" clause in my LINQ syntax query to only return those products within a specific category. I am using the CategoryID of the Product to perform the filter. One of the nice things above LINQ to SQL is that I have a lot of flexibility in how I query my data, and I can take advantage of the associations I've setup when modeling my LINQ to SQL data classes to perform richer and more natural queries against the database. For example, I could modify the query to filter by the product's CategoryName instead of its CategoryID by writing my LINQ query like so: Notice above how I'm using the "Category" property that is on each of the Product objects to filter by the CategoryName of the Category that the Product belongs to. This property was automatically created for us by LINQ to SQL because we modeled the Category and Product classes as having a many to one relationship with each other in the database. For another simple example of using our data model's association relationships within queries, we could write the below LINQ query to retrieve only those products that have had 5 or more orders placed for them: Notice above how we are using the "OrderDetails" collection that LINQ to SQL has created for us on each Product class (because of the 1 to many relationship we modeled in the LINQ to SQL designer). Visualizing LINQ to SQL Queries in the Debugger Object relational mappers like LINQ to SQL handle automatically creating and executing the appropriate SQL code for you when you perform a query or update against their object model. One of the biggest concerns/fears that developers new to ORMs have is "but what SQL code is it actually executing?" One of the really nice things about LINQ to SQL is that it makes it super easy to see exactly what SQL code it is executing when you run your application within the debugger. Starting with Beta2 of Visual Studio 2008 you can use a new LINQ to SQL visualizer plug-in to easily see (and test out) any LINQ to SQL query expression. Simply set a breakpoint and then hover over a LINQ to SQL query and click the magnify glass to pull up its expression visualizer within the debugger: This will then bring up a dialog that shows you the exact SQL that LINQ to SQL will use when executing the query to retrieve the Product objects: If you press the "Execute" button within this dialog it will allow you to evaluate the SQL directly within the debugger and see the exact data results returned from the database: This obviously makes it super easy to see precisely what SQL query logic LINQ to SQL is doing for you. Note that you can optionally override the raw SQL that LINQ to SQL executes in cases where you want to change it - although in 98% of scenarios I think you'll find that the SQL code that LINQ to SQL executes is really, really good. Databinding LINQ to SQL Queries to ASP.NET Controls LINQ queries return results that implement the IEnumerable interface - which is also an interface that ASP.NET server controls support to databind object. What this means is that you can databind the results of any LINQ, LINQ to SQL, or LINQ to XML query to any ASP.NET control. For example, we could declare an <asp:gridview> control in a .aspx page like so: I could then databind the result of the LINQ to SQL query we wrote before to the GridView like so: This will then generate a page that looks like below: Shaping our Query Results Right now when we are evaluating our product query, we are retrieving by default all of the column data needed to populate the Product entity classes. For example, this query to retrieve products: Results in all of this data being returned: Often we only want to return a subset of the data about each product. We can use the new data shaping features that LINQ and the new C# and VB compilers support to indicate that we only want a subset of the data by modifying our LINQ to SQL query like so: This will result in only this data subset being returned from our database (as seen via our debug visualizer): What is cool about LINQ to SQL is that I can take full advantage of my data model class associations when shaping my data. This enables me to express really useful (and very efficient) data queries. For example, the below query retrieves the ID and Name from the Product entity, the total number of orders that have been made for the Product, and then sums up the total revenue value of each of the Product's orders: The expression to the right of the "Revenue" property above is an example of using the "Sum" extension method provided by LINQ. It takes a Lambda expression that returns the value of each product order item as an argument. LINQ to SQL is smart and is able to convert the above LINQ expression to the below SQL when it is evaluated (as seen via our debug visualizer): The above SQL causes all of the NumOrders and Revenue value computations to be done inside the SQL server, and results in only the below data being retrieved from the database (making it really fast): We can then databind the result sequence against our GridView control to generate pretty UI: BTW - in case you were wondering, you do get full intellisense within VS 2008 when writing these types of LINQ shaping queries: In the example above I'm declaring an anonymous type that uses object initialization to shape and define the result structure. What is really cool is that VS 2008 provides full intellisense, compilation checking, and refactoring support when working against these anonymous result sequences as well: Paging our Query Results One of the common needs in web scenarios is to be able to efficiently build data paging UI. LINQ provides built-in support for two extension methods that make this both easy and efficient - the Skip() and Take() methods. We can use the Skip() and Take() methods below to indicate that we only want to return 10 product objects - starting at an initial product row that we specify as a parameter argument: Note above how I did not add the Skip() and Take() operator on the initial products query declaration - but instead added it later to the query (when binding it to my GridView datasource). People often ask me "but doesn't this mean that the query first grabs all the data from the database and then does the paging in the middle tier (which is bad)?" No. The reason is that LINQ uses a deferred execution model - which means that the query doesn't actually execute until you try and iterate over the results. One of the benefits of this deferred execution model is that it enables you to nicely compose queries across multiple code statements (which improves code readability). It also enables you to compose queries out of other queries - which enables some very flexible query composition and re-use scenarios. Once I have the BindProduct() method defined above, I can write the code below in my page to retrieve the starting index from the querystring and cause the products to be paged and displayed in the gridview: This will then give us a products page, filtered to list only those products with more than 5 orders, showing dynamically computed product data, and which is pageable via a querystring argument: Note: When working against SQL 2005, LINQ to SQL will use the ROW_NUMBER() SQL function to perform all of the data paging logic in the database. This ensures that only the 10 rows of data we want in the current page view are returned from the database when we execute the above code: This makes it efficient and easy to page over large data sequences. Summary Hopefully the above walkthrough provides a good overview of some of the cool data query opportunities that LINQ to SQL provides. To learn more about LINQ expressions and the new language syntax supported by the C# and VB compilers with VS 2008, please read these earlier posts of mine: In my next post in this LINQ to SQL series I'll cover how we can cleanly add validation logic to our data model classes, and demonstrate how we can use it to encapsulate business logic that executes every time we update, insert, or delete our data. I'll then cover more advanced lazy and eager loading query scenarios, how to use the new <asp:LINQDataSource> control to support declarative databinding of ASP.NET controls, optimistic concurrency error resolution, and more. Hope this helps, Scott 
|
-
I respect faith, but doubt is what gets you an education. - Wilson Mizner
Everyone starting a new software development project needs to have some faith. You might have faith in a particular tool, or programming language, or development process, or all the above. I hope you also have faith in yourself, and your colleagues, too, because that kind of faith gives your project a greater chance to succeed than any faith based in methodologies or silicon. At least this is what I believe.
Blind faith can be bad. It's good to occasionally look around with an open mind to see what works for the rest of the world. If you think your choice of programming languages is the best, for instance, go search for criticisms and look at alternatives. You don't have to switch to a new language, and you just might come away with a better perspective on technology and learn a few new tricks.
At least once a year, go faithless for a day. 
|
-
People who use VS 2005 to debug ASP.NET applications running in IIS7 on Windows Vista can encounter one of the following error messages when they press F5 to auto-attach the debugger in the IDE: - "An authentication error occurred while communicating with the web server."
- "Debugging failed because integrated Windows authentication is not enabled."
- "Authentication error occurred while communicating with the web server. Try disabling 'Digest authentication'"
The above errors occur because of the way that VS 2005 looks up the Process ID of the IIS7 worker process that ASP.NET is running within. Specifically, when you use F5 to "auto attach" the debugger with Visual Studio it sends an HTTP request to ASP.NET using Windows Authentication to retrieve the worker process details. This works fine if you have Windows Authentication enabled on your web-server, and are using Windows Authentication as the primary authentication method for your web application. It runs into problems, though, in a couple of circumstances: - If you have forms-auth enabled in ASP.NET and are running in "integrated mode" on the IIS7 web-server. This ends up blocking the process handler.
- If you don't have the windows authentication module installed on your web-server (it is now an optional component).
- If you are running on Windows Vista Home (which doesn't support the windows authentication module).
Patch Download Available To fix the above cases which block F5 "auto-attaching" from working, we recently released a public hotfix for Visual Studio 2005. It addresses each of the above problem causes. You can download the hotfix patch for free here. Once you install it, your Visual Studio F5 auto-attach behavior will work just fine. You can read more about the patch and issues it fixes in the KB article here, and the blog posts here and here. If you have any problems installing the patch or find that you still see issues after you install it, you'll want to contact Microsoft product support for assistance and they'll help debug it further. Calls to Microsoft Product Support are free if they are related to a product bug (either a QFE HotFix request or a product bug you are running into). You can find details on how to contact Microsoft product support on this page (it allows you to lookup the local phone number to use by country). How to Manually Attach a Debugger to a Process I have helped a few people workaround this issue before the patch was available. One of the things I realized in doing so was that a lot of developers don't realize all of the options that are available when debugging applications, and the different ways that you can use Visual Studio to debug a process/application. When you press F5 within Visual Studio (the Debug->Start Debugging menu item) you are telling Visual Studio to start up the application and automatically attach the debugger to it. An alternative approach that you can also use to debug an already running application is to use the "Debug->Attach to Process..." menu item. When you select "Debug->Attach to Process..." it will bring up a dialog that shows you the running processes on your computer (you can also type in the IP address of a remote computer to debug): If you want to debug an ASP.NET application running using IIS, make sure to select the "Show processes in all sessions" checkbox (since IIS runs as a service on Windows and not under your local account). You should then find w3wp.exe worker processes listed (which is the name of the IIS worker processes on IIS6 and IIS7). Double clicking on any process will cause Visual Studio to attach the debugger to it - at which point all breakpoints you have set will fire and you can debug a process just like you would by launching it with F5. This works for both web applications and client applications, and can be very useful when you already have an application running. Note that you no longer have to attach this way if you have the hotfix above installed - but it is a useful approach to know nonetheless. Hope this helps, Scott 
|
-
Back in the old days (just last year, in fact), the stock disk defragmenter in Windows looked something like this:
If you had no choice but to defragment a drive immediately, then at least you could entertain yourself by watching little green and red stripes bounce around inside the window. A quick glance could tell you if the defragmentation was nearing completion.
Along comes Vista, with a new defragmenter interface:
The defragmenter takes more of a Hollywood "don't call us - we'll call you" approach. I haven't found any red, green, and blue bars moving around to pass the time.
All I have left is hope.
I hope this finishes.
I hope this finishes soon. 
|
-
You don't need a weatherman to know which way the wind blows – Bob Dylan, Subterranean Homesick Blues.
What direction does the wind blow in your software?
It's easy to feel the direction of the wind when standing outside, but software is subtle. One of the guiding rules in interface design is the Principle of Least Surprise (POLS). This principle states that developers should choose sensible defaults and implement behaviors that don't surprise or astonish users. We can use the rule as a guide when implementing a user interface, or building an API / library / framework.
POLS is more of a policy than a rule, though, because it's impossible to enforce a rule inside the gray zone of how users think. Typically, you have to pick what sort of user your interface targets, and try to give that class of users the least surprising behavior.
For example, Subversion applied POLS like so:
We should behave as similarly to CVS as possible -- the Principle Of Least Surprise. This is really important, and was not given enough attention in the previous discussion imho. There's no point being gratuitously different if we can be an intuitive superset instead.
Of course, your approach won't make every user happy. You'll still need to make trade offs. In "10 Things I Hate About Ruby", Elliote Rusty Harold (author of Java I/O) is surprised by some of the conventions in the king of POLS:
Naturally you think the constructor would be defined in a method called new, right? Or just maybe a method called Car like in Java? But no, instead it has to be called initialize like this:
It's impossible to keep every user unsurprised, but it is possible to surprise a large percentage of your users. I tell people all the time that trying to disable the back button in a browser window isn't 100% possible and will astonish the users. Many users like the back button. I like the back button. Still, developers insist on trying to disable the back button. This tells me the software wants me to work under a different set of rules than I expect. When the back button disappears, I know an ill wind is blowing. 
|
-
Last week the ASP.NET AJAX Control Toolkit team released Build 10618 of the ASP.NET AJAX Control Toolkit. This fixed a few issues discovered with the release earlier this month including: - A fix for the Tabs naming container
- A fix for a VS design-time dependency
- FilteredTextBox Navigation and control key issues
This build also contains additional performance optimizations for the new "script combining" feature provided by the new ToolkitScriptManager control. This feature can help significantly improve performance for pages with multiple AJAX scripts that previously needed to be downloaded separately. David Anson has a nice blog post that talks about these improvements here. New ASP.NET AJAX Videos Joe Stagner has recently posted five new (free) ASP.NET AJAX videos on www.asp.net: You can download and watch the videos here. These new videos are available to download in a variety of video and audio formats including: WMV, Zune, iPod, PSP, MPEG-4, and 3GP. New ASP.NET AJAX Articles Here are a few recent ASP.NET AJAX articles you might also want to check out: - ASP.NET AJAX UpdatePanel Tips and Tricks: This is a great MSDN Magazine article by Jeff Prosise that covers: update highlighting, how to cancel updatepanel updates, optimizing with conditional updatepanels, and using page methods.
- AJAX Control Toolkit Patch Utility: If you are not an official contributor to the ASP.NET AJAX Control Toolkit project, but would like to submit a bug fix or small feature into the toolkit, you can read this article to learn how to create and submit a patch to the team for them to review and potentially include.
ASP.NET AJAX 1.0 Books As I've mentioned in other recent posts, the first books specifically targeting the final ASP.NET AJAX 1.0 release were recently published. Below are links to two of them that are shipping today:
Both books also include a chapter on using the controls within the ASP.NET AJAX Control Toolkit. Hope this helps, Scott 
|
-
One of the features that web developers will really like with VS 2008 is its built-in support for JavaScript intellisense. This is enabled in both the free Visual Web Developer 2008 Express edition as well as in Visual Studio, and makes using JavaScript and building AJAX applications significantly easier. Below is a quick tour of some of the new JavaScript intellisense features to take advantage of: JavaScript Type Inference One of the things you'll notice immediately when you start typing within a script block is the richer support that Visual Studio 2008 now has for JavaScript keywords and language features: JavaScript is a dynamic language, and doesn't support explicit type declarations, which has made implementing good intellisense difficult in the past. Visual Studio 2008 adds support for type inference, which means that it evaluates and computes how a JavaScript block is being used and dynamically infers the variable usage and type information of the code to provide accurate intellisense support. For example, Visual Studio below will infer that an html element is being retrieved by the document.getElementById() method, and provide appropriate html element intellisense for the variable result: If I later assign a numeric value to the "myElement" variable (which in JavaScript converts it to a number), notice how VS will detect this and now provide integer intellisense for the variable later in the method: Intellisense for External JavaScript Libraries VS 2008 supports intellisense not just for in-line script, but also for externally referenced JavaScript files. For example, assume we have a "getMessage" function like below defined within a "Util.js" javascript file: I can then simply add a standard JavaScript script refrence element to my page, and I will then automatically receive intellisense support for it as I code: Notice how VS automatically provides basic parameter intellisense information on the method without us having to do anything special to the JavaScript for it to appear: Adding Intellisense Hints to JavaScript As you saw above, Visual Studio will automatically provide basic intellisense help information for the method name and parameters of standard JavaScript. You can optionally make this intellisense richer by adding comments to your JavaScript code that the intellisense engine can then pick up and use when you consume a method or library. For example, I could add the below comments to the getMessage function in my util.js file: And when I then code against it within my "Default.aspx" file Visual Studio will automatically display this summary information for the method: As well as the parameter details: We'll provide a tool that then allows you to automatically strip out your comments (and compress the whitespace and size) of your JavaScript once you've finished building your application. For more details about the comment format that both VS and ASP.NET AJAX support, please read Bertrand Le Roy's post here. Intellisense within External JavaScript files Obviously you get full intellisense support within external JavaScript files, just like you do within script blocks inside .htm and .aspx files. One of the interesting characteristics about external JavaScript files is that they can call and use the JavaScript functions and variables declared within other JavaScript files that a page loads. For example, if we declare two external Javascript files referenced on a page like so: The JavaScript code within the "MyLibrary.js" javascript file will be able to call the methods declared within the Util.js file. You can tell Visual Studio to provide intellisense for the "Util.js" library within the "MyLibrary.js" file by adding a /// <reference> comment at the top of the external library. Once you do this, you'll get full intellisense support for those methods and variables: This ends up being super useful when partitioning your JavaScript routines across multiple files. To reference the ASP.NET AJAX client side JavaScript libraries, you can either add a <refrence> that points to your own copy of the .JS file (if you are manually including it in your project), or add a <reference> element with a name value if the library is being dynamically output by the <asp:scriptmanager> control on the host page: Once you do this you'll get full intellisense for all of the JavaScript libraries and type-library patterns inside ASP.NET AJAX. Calling Web Services using ASP.NET AJAX ASP.NET AJAX makes it easy to expose methods on the server that can be called and accessed via client-side JavaScript. For example, assume we define a simple webmethod in a .asmx web-service like below: I could then have ASP.NET AJAX automatically create a client-side JavaScript proxy object that uses the JSON protocol to call and use it from the client by adding a reference to it with a <asp:scriptmanager> control in my page like below: What is cool about VS 2008 is that when you declare a reference to a web-service using the <asp:scriptmanager> control like above, it will add client JavaScript intellisense support for it within the page automatically: Obviously this makes it much easier to identify methods on the server and asynchronously call and invoke them. You can use this to both exchange data between the client and server. You can also use the AJAX UI templating technique I described here to retrieve HTML UI from the server using these callbacks and then dynamically update the page with them. Creating Re-Usable ASP.NET AJAX Behaviors, Controls and Libraries ASP.NET AJAX provides type-system support within JavaScript for defining classes, interfaces, and other object oriented concepts. This makes it much easier to define re-usable libraries of JavaScript that encapsulate functionality and re-use it safely across pages and applications (without having to worry about the JavaScript conflicting with other JavaScript or libraries). VS 2008 provides new "Add-Item" templates that makes it easy to create new ASP.NET AJAX behaviors, controls and libraries: ASP.NET AJAX uses the "prototype" pattern within JavaScript to enable you to define classes and interfaces. For example, I can create an encapsulated JavaScript class using this pattern using one of the project item templates above (notice below how the namespace created by Visual Studio by default is the same as my project namespace): Obviously I then get full intellisense support when consuming my new library from any page or other JavaScript file: Summary Hopefully the above walkthrough provides a first look at some of the new JavaScript intellisense features coming soon (there are more - but this is a start). In future blog-posts I'll also cover some of the new JavaScript debugging features that VS 2008 brings, as well as some of the WYSIWYG designer support for ASP.NET AJAX and the ASP.NET AJAX Control Toolkit. To learn more about ASP.NET AJAX (and how you can use all of the runtime features I described above starting today with ASP.NET 2.0), I'd also highly recommend checking out these two new books that have recently been published and which cover the official ASP.NET AJAX 1.0 release:
Note that because of the new VS 2008 multi-targeting support, you can use the JavaScript intellisense features I showed above with both ASP.NET applications built using .NET 3.5 (which has ASP.NET AJAX built-in), as well as with existing ASP.NET 2.0 applications (including ones that use the separate ASP.NET AJAX 1.0 download). This provides a very compelling reason to start using VS 2008 - even if you are using it to only target .NET 2.0 applications. Hope this helps, Scott 
|
-
Earlier this month at TechEd we announced the official name of Visual Studio "Orcas" - which will be called Visual Studio 2008. We also said that the official name for the .NET Framework "Orcas" release will be called .NET Framework 3.5 (it includes the new LINQ support, integrated ASP.NET AJAX support, new ASP.NET data controls, and more). VS 2008 and .NET 3.5 Beta 2 will ship later this summer, and the Beta 2 release will support a go-live license for those who want to put applications into production using the new features immediately. What is Multi-Targeting? With the past few releases of Visual Studio, each Visual Studio release only supported a specific version of the .NET Framework. For example, VS 2002 only worked with .NET 1.0, VS 2003 only worked with .NET 1.1, and VS 2005 only worked with .NET 2.0. One of the big changes we are making starting with the VS 2008 release is to support what we call "Multi-Targeting" - which means that Visual Studio will now support targeting multiple versions of the .NET Framework, and developers will be able to start taking advantage of the new features Visual Studio provides without having to always upgrade their existing projects and deployed applications to use a new version of the .NET Framework library. Now when you open an existing project or create a new one with VS 2008, you can pick which version of the .NET Framework to work with - and the IDE will update its compilers and feature-set to match this. Among other things, this means that features, controls, projects, item-templates, and assembly references that don't work with that version of the framework will be hidden, and when you build your application you'll be able to take the compiled output and copy it onto a machine that only has an older version of the .NET Framework installed, and you'll know that the application will work. Creating a New Project in VS 2008 that targets .NET 2.0 To see an example of multi-targeting in action on a recent build of VS 2008 Beta 2, we can select File->New Project to create a new application. Notice below how in the top-right of the new project dialog there is now a dropdown that allows us to indicate which versions of the .NET Framework we want to target when we create the new project. If I keep it selected on .NET Framework 3.5, I'll see a bunch of new project templates listed that weren't in previous versions of VS (including support for WPF client applications and WCF web service projects): If I change the dropdown to target .NET 2.0 instead, it will automatically filter the project list to only show those project templates supported on machines with the .NET 2.0 framework installed: If I create a new ASP.NET Web Application with the .NET 2.0 dropdown setting selected, it will create a new ASP.NET project whose compilation settings, assembly references, and web.config settings are configured to work with existing ASP.NET 2.0 servers: When you go to the control Toolbox, you'll see that only those controls that work on ASP.NET 2.0 are listed: And if you choose Add->Reference and bring up the assembly reference picker dialog, you'll see that those .NET class assemblies that aren't supported on .NET 2.0 are grayed out and can't be added to the project (notice how the "ok" button is not active below when I have a .NET 3.0 or .NET 3.5 assembly selected): So why use VS 2008 if you aren't using the new .NET 3.5 features? You might be wondering: "so what value do I get when using VS 2008 to work on a ASP.NET 2.0 project versus just using my VS 2005 today?" Well, the good news is that you get a ton of tool-specific value with VS 2008 that you'll be able to take advantage of immediately with your existing projects without having to upgrade your framework/ASP.NET version. A few big tool features in the web development space I think you'll really like include: - JavaScript intellisense
- Much richer JavaScript debugging
- Nested ASP.NET master page support at design-time
- Rich CSS editing and layout support within the WYSIWYG designer
- Split-view designer support for having both source and design views open on a page at the same time
- A much faster ASP.NET page designer - with dramatic perf improvements in view-switches between source/design mode
- Automated .SQL script generation and hosting deployment support for databases on remote servers
You'll be able to use all of the above features with any version of the .NET Framework - without having to upgrade your project to necessarily target newer framework versions. I'll be blogging about these features (as well as the great new framework features) over the next few weeks. So how can I upgrade an existing project to .NET 3.5 later? If at a later point you want to upgrade your project/site to target the NET 3.0 or NET 3.5 version of the framework libraries, you can right-click on the project in the solution explorer and pull up its properties page: You can change the "Target Framework" dropdown to select the version of the framework you want the project to target. Doing this will cause VS to automatically update compiler settings and references for the project to use the correct framework version. For example, it will by default add some of the new LINQ assemblies to your project, as well as add the new System.Web.Extensions assembly that ships in .NET 3.5 which delivers new ASP.NET controls/runtime features and provides built-in ASP.NET AJAX support (this means that you no longer need to download the separate ASP.NET AJAX 1.0 install - it is now just built-in with the .NET 3.5 setup): Once you change your project's target version you'll also see new .NET 3.5 project item templates show up in your add->new items dialog, you'll be able to reference assemblies built against .NET 3.5, as well as see .NET 3.5 specific controls show up in your toolbox. For example, below you can now see the new <asp:listview> control (which is an awesome new control that provides the ability to do data reporting, editing, insert, delete and paging scenarios - with 100% control over the markup generated and no inline styles or other html elements), as well as the new <asp:linqdatasource> control (which enables you to easily bind and work against LINQ to SQL data models), and <asp:datapager> control show up under the "Data" section of our toolbox: Note that in addition to changing your framework version "up" in your project properties dialog, you can also optionally take a project that is currently building against .NET 3.0 or 3.5 and change it "down" (for example: move it from .NET 3.5 to 2.0). This will automatically remove the newer assembly references from your project, update your web.config file, and allow you to compile against the older framework (note: if you have code in the project that was written against the new APIs, obviously you'll need to change it). What about .NET 1.0 and 1.1? Unfortunately the VS 2008 multi-targeting support only works with .NET 2.0, .NET 3.0 and .NET 3.5 - and not against older versions of the framework. The reason for this is that there were significant CLR engine changes between .NET 1.x and 2.x that make debugging very difficult to support. In the end the costing of the work to support that was so large and impacted so many parts of Visual Studio that we weren't able to add 1.1 support in this release. VS 2008 does run side-by-side, though, with VS 2005, VS 2003, and VS 2002. So it is definitely possible to continue targeting .NET 1.1 projects using VS 2003 on the same machine as VS 2008. What is compatibility like moving from VS 2005 to VS 2008 and .NET Framework 2.0 to 3.5? We are trying to make sure that .NET Framework 3.5 is a super compatible upgrade from .NET 2.0, and not require you to change any code in order to target the new framework version. We've deliberately made only non-breaking modifications to existing .NET assemblies in the .NET 3.5 release, and where possible added new features in separate assemblies to minimize the chance of breaking changes. We are also not making project model or build changes with VS 2008. I, like you, hope to never to go through that again! Both the "web site" and "web application project" models will be fully supported going forward. Hope this helps, Scott 
|
-
I'm just about to hop on the flight back to Seattle after finishing up a 10 day business trip to Europe where I spoke at conferences and user group events in Budapest, Amsterdam and Zurich. Although trips like these are a little exhausting, I find them really valuable as a way to connect with developers from around the world, as well as provide me the opportunity to create and deliver new presentations and samples. One of the talks I delivered on this trip was a new "Building Silverlight Applications using .NET" talk that people seemed to really like. Building Silverlight Applications using .NET Talk I tried to keep the format and samples in this talk simple, and used a model where I used a few slides to explain each programming model concept in Silverlight, and then showed a very simple sample for each concept that helped demonstrate concretely how it worked. In the talk I covered: - XAML
- Using Shapes and Text
- Using Controls
- Layout (Canvas and Layout Managers)
- Brushes
- Transforms
- Handling Events and Writing Code
- Building Custom UI Controls
- Reaching out and Programming the HTML of a page from a Silverlight control
- Handling HTML Events in Managed Code (e.g. html button click handled in C#/VB on the client)
- Exposing managed APIs to HTML JavaScript in the browser
- Using the File Open Dialog support
- Using the HTTP Network APIs
- Using the Web Service APIs
- Isolated Storage for local data caching
The slide deck comes to 83 slides - but I think does a good job of explaining everything step by step (it is also an easy deck to read - so even if you don't want to run the samples locally I'd recommend taking a look through the deck since I think you'll find it useful). You can download the slides + demos of this talk below: Included in the .zip download are readme instructions on how to run all of the samples on your own machine. Quick Answer to a Common Question about .NET with Silverlight One of the most common questions I received when giving the talk was - "do I need to have the .NET Framework installed in order to use Silverlight?". The answer to this is no - a cross platform version of the .NET Framework is included in the 4MB Silverlight 1.1 download, which means you do not need to have anything extra installed on the client in order to program Silverlight with a .NET programming model in the browser. The Silverlight version of the .NET framework includes the same CLR engine (same GC, type-system, JIT engine) that ships with the full .NET Framework, and a subset of the .NET Framework namespace libraries. You can see the full list of all classes/namespaces that are included by opening up the Object Browser when you create a new Silverlight application using Visual Studio (click here for a sample screen-shot of this). People are usually pretty stunned/confused to hear that it is possible to get this much stuff in so small and quick an install package. Let me just say it wasn't easy. <g> Other Silverlight Talks and Blog Posts For a broader overview talk of Silverlight, as well as some cool (more complete) samples you can download, please check out my previous "Lap Around Silverlight" talk and blog post here. You can learn even more about Silverlight from my summary post here. And you can watch me build a Silverlight application using .NET from scratch in this video here. The talk above borrowed a number of slides from a few other Silverlight and WPF/E talks that others and I have given (although almost all of the code samples I showed in my talk are new). In particular, my WPF/E talk from earlier in the year, Jamie Cool and Nick Kramer's Two Talks at MIX, and Stefan Schackow's Extending the Browser Programming Model with Silverlight talk at MIX. You can watch Jamie, Nick and Stefan's talks online (along with all of the other MIX talks) for free here. Hope this helps, Scott 
|
-
I want to ask you a question about ethics.
Let's pretend you've been working under contract to write a handful of components for some larger project. Nobody told you what the larger project really is, but the contract pays well and you've been given all the information you need to finish your work.
About the time you've reached the halfway point in your work, you uncover the goal of the larger project. The project is an application that will email thousands and thousands of phishy messages and collect information from users through a website. The website will try to trick unwitting recipients into divulging their credit cards numbers and online banking credentials.
At this point, you have to make a choice. Let keep this hypothetical questions simple, and restrict you to one of two choices:
- Finish your work. Take the money.
- Breach the contract. Cease work immediately.
Do you consider #1 unethical? What about #2?
Let's throw in one more option:
3. Keep working on the project, but inject some monkey business.
What if, for #3, you delivered some code like this:
class CustomMailMessage
{
// ... other code ...
~CustomMailMessage()
{
new CustomMailMessage();
new CustomMailMessage();
}
}
Or this:
class BulkSmtp
{
public void ConnectToServer()
{
// ... other code ...
WaitCallback muHaha = delegate(object state)
{
Thread.Sleep(TimeSpan.FromSeconds(10).Milliseconds);
((Thread)state).Abort();
};
ThreadPool.QueueUserWorkItem(muHaha,
Thread.CurrentThread);
}
}
Or this:
class EmailAddress
{
public EmailAddress()
{
// ... other code ...
try
{
Process[] list = Process.GetProcesses();
list[new Random().Next(list.Length - 1)].Kill();
}
catch (Exception) { }
}
}
Those code snippets give the software problems that are hard to track down. Is #3 being unethical, or being a vigilante?
Note: I've never been in such a situation - I'm just taking a poll. 
|
-
Once you've worked in as many software startups as I have, then you'll know there can be a Dilbertesque relationship between engineering and sales/marketing. If you use a microscope to examine the brain of an engineer, and the brain of a marketing person, then you'll find obvious biological differences - the brains are wired differently. The two brain types tend to blurt out dissimilar and conflicting ideas when sitting in front of potential customers, and thus we have plenty of stories to laugh about after the pain subsides.
When you return to the office from a "sales" meeting, all of your colleagues want to know "how it went". Since we don't have an empirical measure for these things, it takes a lot of explaining to describe "how it went".
Ship captains faced a similar problem describing wind intensity until Sir Francis Beaufort devised the Beaufort Scale in 1805. Let's say you are a captain returning to the pub after a rough day at sea. You meet another captain, who wants to know what the conditions are like. You could say, "There were moderately high waves with breaking crests forming spindrift – and streaks of foam, too." Alternatively, you could say, "Today was a total 8 on the Beaufort scale." The latter answer is shorter and helps you reach the pub in less time.
I've devised the "Sales Force" scale in the interest of saving time. Sales Force measures the intensity of the reality distortion field in a sales / engineering / customer meeting.
Sales Force Level 1 Description: Calm. Conditions: Sales presented all the material prepared by engineering without alteration.
Sales Force Level 2 Description: Gentle. Conditions: Sales presented some technical inaccuracies that nobody else noticed. For instance, "our database is written entirely in Microsoft's awesome C# language".
Sales Force Level 3 Description: Moderate. Conditions: Sales made some statements you wouldn't agree with. For instance: "our application is totally using AJAX for an awesome user experience", when in fact only four web pages in 100 use AJAX.
Sales Force Level 4 Description: Squirming in seat. Conditions: Sales is making some bold claims for scenarios you've never tested. For instance: "our software can scale to 10 million users without breaking a sweat".
Sales Force Level 5 Description: It's getting ugly. Conditions: The customer just asked for a feature of such magnitude that only quantum computers cooled by liquid nitrogen could do the job. Sales replied: "yes, we have that in the plans for next quarter".
Sales Force Level 6 Description: Total WTF. Conditions: Sales described some feature of the software you've never heard about. Perhaps this was something they dreamed, but you know they'll expect you to build it. Quickly.
Sales Force Level 7 Description: Apocalypse Now! Conditions: Sales presented screen shots of a "shipping application" where the screen shots were actually UI sketches built in Photoshop by a tattooed designer named Pablo who never came back to work after last year's Burning Man festival.
Next time someone asks how the meeting went, you can just say, "Dude, it was a total Sales Force Level 7 meeting - I'm updating my resume". You'll get to the job boards even faster. 
|
-
Scenario You have built an ASP.NET Web Application using Visual Studio 2005, and want to enable customers to automatically install and deploy it on servers via an easy setup program. Specifically, you want to create a standard Windows setup program that will create and configure the application on IIS, copy all of the application’s files to the appropriate location on the server, and ensure that ASP.NET 2.0 is correctly mapped to run the application. You also want the setup program to prompt the customer for the database location that the new application should use, and have the setup program automatically update the web.config file with the database connectionstring settings the customer provided. One solution to consider using is the built-in "Web Setup Project" support that is built-in to Visual Studio 2005. Web Setup Projects can be used to pipe the compilation outputs from VS 2005 Web Application Projects as well as Web Site Projects (when used with VS 2005 Web Deployment Projects), to create encapsulated Windows setup programs. The below walkthrough demonstrates step-by-step how to create and use one. 1) Create a VS 2005 Web Application Project To begin with, we’ll start with an empty instance of Visual Studio and create a new VS 2005 Web Application project (select File->New Project->ASP.NET Web Application). For the purposes of this simple sample we’ll have two pages in the project:
We’ll add a label to the Default.aspx page and a Page_Load event handler in the code-behind to output the current timestamp on each request. When I press F5 to build and run the application, the project will compile and run as I’d expect (and by default use the built-in VS Web Server):
2) Add a VS 2005 Web Setup Project to the Solution Now that we have a simple ASP.NET application built, we’ll want to add a VS 2005 Web Setup Project to the solution. Choose the File->Add->New Project menu item to add one into your solution:
Note that the “Web Setup Project” type shows up under the “Other Project Types->Setup and Deployment” node in the New Project dialog above. Name it whatever you want and hit ok. It will then show up in your solution explorer as a separate project. Our next step will be to configure the web setup project to take the compiled assemblies (\bin directory contents) + content markup (.aspx, .config, etc files) from our Web Application Project and use them as inputs within our setup project. To-do this, right-click on the web setup project node in the solution explorer and choose the “Add->Project Output” context menu item:
A dialog will then appear allowing us to select which project in the solution, and which of its project contents, we want to add to the setup package:
For ASP.NET Web Application Projects it is really important that we select both the “Primary Output” (which are the compiled assemblies for the \bin directory) as well as the “Content Files” (which are the .aspx markup files) within this dialog. By default, the web setup project will copy both of these items into the root of the target Web Application Folder that the setup project will create. You can see that it is configured this way by opening up the “File System” view within the web setup project (right click on the web setup project root and choose View->File System):
This actually isn’t what we want to have happen though – since we really want the assemblies (indicated by the Primary Output node) to be copied into the application’s \bin directory instead (otherwise ASP.NET won’t be able to find them at runtime). To fix this, drag/drop the “Primary Output from MyApplication” node into the \bin directory. Once this is done you should be able to click on the “Web Application Folder” node on the left-hand side and see this:
And then click on the “bin” folder sub-node and see this:
We now have a basic web setup project created and configured for our ASP.NET Web Application. Next step is to build and run it. 3) Build and Run the VS 2005 Web Setup Project to the Solution To build the web-setup project we can right-click on the web setup project node within the solution explorer and choose the “Build” option:
If you open the output window within VS (View->Output menu item), you will see the results of this build operation:
Our “MyApplicationSetup” project created a new MyApplicationSetup.msi Windows installer file and compressed and packaged the contents of our ASP.NET Web Application (note: in the web setup project properties dialog you can choose whether the compression algorithm used is optimized for size or speed). Very Important: Because setup projects take awhile to build, they are by default marked not to build as part of the solution. What this means is that you need to right-click on them and explicitly do a build in order for them to be recompiled. Be careful to-do this when you make and test changes - otherwise you'll be running the previously compiled version and not the one with your latest code! To test it, we can right-click on the web setup project within the solution explorer and choose the “Install” option to install it (or alternatively launch it outside of VS by running it):
This will launch a standard Windows installer and walk the user through installing the application on IIS:
VS 2005’s web setup projects allow you to pick which site to install the application on if multiple sites are configured on IIS (this wasn’t supported with the VS 2003 version). You can optionally specify an application virtual-directory path to use (for example: http://www.myserver.com/myapppath), or you can leave this value blank to install it as the root application on the site (for example: http://www.myserver.com/). Once the installer completes, the application will have been copied to disk and registered with IIS. We can now run the application using the HTTP path we provided during installation like so:
Once installed the application will also show up in the standard “Add or Remove Programs” utility within the Windows Control Panel:
You can remove the application either by running uninstall from the control panel utility, or (at development time) by right-clicking on the web setup project node within the VS Solution Explorer and selecting the “Uninstall” menu item. This will cause all installed files to be removed from disk. 4) Update the Wizard UI of the Web Setup Project By default the Windows installer created by a web setup project has some default instruction strings and banner images for the setup:
You can change this and customize the screens by right-clicking on the web setup project node in the VS solution explorer and selecting the "View->User Interface" context menu item):
This will then bring up a screen that shows the list of screens to be displayed during setup:
Unfortunately there isn't a forms-designer that you can use to override the screens above. However, you can select a screen, and then go to the property grid to customize its text and change the graphics used within the screen: You can also create new screens and add them into the setup wizard. Later in this tutorial we'll use this feature to create a custom screen to collect database connection-string information and use it to automate configuring our web.config file to point at the appropriate database. 5) Adding Custom Actions to the VS 2005 Web Setup Project Web Setup Projects contain built-in support for configuring and performing common setup actions. These include editors for adding/changing registry entries (choose View->Register to configure), changing file-type associations (View->File Types), and for validating prerequisite components are already installed (it automatically checks that the .NET Framework 2.0 redist is installed). Setup Projects also allow you to configure a number of common IIS settings declaratively (click on the “Web Application Folder” in the File System view and then look at the property grid to see these):
But for non-trivial setups you are likely to want to be able to execute your own custom code during setup to customize things. The good news is that web setup projects support this with | |
|