Scott Hanselman

PDC Preparation Presses...

October 17, '08 Comments [16] Posted in ASP.NET | ASP.NET MVC | PDC | Windows Client | WPF
Sponsored By

Getting reading for my talk at PDC 2008. 75 minutes just isn't enough time to cover everything. I hope the talk doesn't suck. Here's what my home office looks like as I'm getting my demos ready.

photo

I was reminiscing by looking through the nine pages of my blog's PDC category just now. It was interesting to look at what I said about PDC 2003 in conclusion. (Yikes, 5 years ago?)

What I remember most about PDC 2003 was that I used my Blackberry (at the time) to Live Blog the whole keynote. Remember this is five years ago, before wireless was everywhere and a bit before keynote live blogging was really common. Hurt my fingers and hands a LOT as I recall.

Here's one of the posts I did from my Blackberry at the time:

* using System.MessageBus - the namespace for Indigo, interesante.
* Now, Don is going to use the Indigo system to post directly to his blog (http://www.gotdotnet.com/team/dbox) from the stage.
* They are checking out his blog, and they see that he hasn't blogged since last night.
* BOOM.  Posted.  Check it out.
* Now, they've switched to VB.NET (apparently Chris has been in the closet, and has been attracted to VB.NET since he was 5, but could never explain his feelings.  Don wonders if he could do both languages...)
* Now they've added a component to the sidebar that will receive an Indigo message from their client.  So they'll be talking "Indigo Messaging" for Interprocess Communication.  They added a TextPanel to the SideBar and pushed text out to it.
Scott Hanselman - Corillian Corp
--------------------------
Sent from my BlackBerry Wireless Handheld

Ah, good times. I hope to see you at PDC! My talk is on the first day, Monday at 5:15.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Microsoft Web Application Installer - Open Source Web Apps Delivered and Installed

October 17, '08 Comments [24] Posted in ASP.NET | Open Source | Programming | Source Code | Tools
Sponsored By

image Remember last week when I mentioned the Microsoft Web Platform Installer? It's an bootstrapper that gets you setup for free web development, all in a single application. It'll setup IIS7, get you Visual Studio, SQL Server, .NET, etc. Cool. And there was much rejoicing (except XP folks, sorry.)

Well, the team just released the Web Application Installer (Beta). Get it? First Platform, now Applications.

What does it do? Well, how about a screenshot.

Microsoft Web Application Installer (Beta)

Yes, that's Drupal in there. And PHPBB. And WordPress. Sweet.

I've talked to the team, and they've promised that DasBlog is next in line to get in that list o' applications. It's a *ahem* gem of an application. Well, it's a great start. Open Source, baby, baby.

The installer knows about prerequisites, although the app can't currently install them for you. However, it'll point you to all the correct places to get what you need.

Microsoft Web Application Installer (Beta) (2)

When you've satisfied the prerequisites, it'll setup IIS for you, prompt you for application-specific configuration and you're up and running. It'll also validate the configuration so you'll know ahead of time if the app will work.

Microsoft Web Application Installer (Beta) (3)

There are people at Microsoft do care about Open Source. I'm telling you guys and gals, we're turning this ship around. Slowly, but we are.

Oh, by the way, the Web Application Installer uses and ships ICSharpCode.SharpZipLib, which is GPL'ed Open Source. It has an exception, however:

"..gives you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library"

Which is legal Open Source license speak for "link on, brother, link on." There you go, Microsoft ships an app with a mostly GPL'ed library. Madness. Cats and Dogs, living together, mass hysteria!

Go check them out:

They require Vista or Windows Server, x86 or x64 and you'll need admin rights. Enjoy.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

ASP.NET MVC Beta released - Coolness Ensues

October 16, '08 Comments [9] Posted in ASP.NET | ASP.NET Dynamic Data | ASP.NET MVC
Sponsored By

ASP.NET MVC is now officially in Beta. Go get it! ScottGu has all the juicy details in his usually Epic style. In a nutshell, this is called Beta (and not Preview 1138) because the quality and the amount of testing gone into it was higher than the Previews and source drops you may have gotten off of CodePlex. It's API surface is pretty stable now.

Also, we're shipping jQuery with ASP.NET MVC! When you go File | New ASP.NET MVC Project, you've already got jQuery. Bam.

Here's what's new in ASP.NET MVC Beta:

If you've been playing it safe as all the Alpha Geeks have been living on the edge, if you're wondering when would be the time to start using ASP.NET MVC or when you could go live, this is a good time to start. This release as a very clear Go-Live license. Totally, (if you haven't already) go out there and put your sites out in public on ASP.NET MVC if you like. It's pretty much feature complete (again, hence, "Beta") and shouldn't change in any major ways between now and it's release in a coming month ending in "-ber" like January-ber or Next June-ber. (Seriously, I have no idea when it'll be out. When it's done. But, we're closer than we were yesterday. Go ask Phil.)

One of the new additions is Model Binders that formalize the relationship between what's happening in HTTP and what ends up happening in your Controller actions. Similar to what you can do in MonoRail with IParameterBinder, you can now do in ASP.NET MVC. For example, back in June I showed how to handle uploaded files with ASP.NET MVC. It was useful, but hard to test and kind of hard to read.

Here's a cleaner way as an example from Levi Broderick, a Developer on the ASP.NET MVC team.

A Sample ModelBinder for HttpPostedFileBase:

public class HttpPostedFileBaseModelBinder : IModelBinder {

public ModelBinderResult BindModel(ModelBindingContext bindingContext) {
HttpPostedFileBase theFile = bindingContext.HttpContext.Request.Files[bindingContext.ModelName];
return new ModelBinderResult(theFile);
}
}

You'd activate it in your global.asax.cs (or .vb):

ModelBinders.Binders[typeof(HttpPostedFileBase)] = new HttpPostedFileBaseModelBinder();

Then you'd make sure the form in your view uses the correct enctype:

<form enctype="multipart/form-data" method="post" action="{some url}">
Choose file: <input name="theFile" type="file">
<input value="Submit Query" type="submit">
</form>

…and finally, in the action method of your controller:

public ActionResult Upload(HttpPostedFileBase theFile) {

// 'theFile' now contains the uploaded file
}

That's it. There's lots of cool binding stuff you can do, but that's just one example.

One other thing I wanted to say. I was in Las Vegas yesterday keynoting VSLive and I made it a point to show this new slide. It's simple, and perhaps obvious, but perhaps not:

I wanted to make it clear that even though folks (and me) might use the term "hybrid" to refer to ASP.NET applications that mix WebForms, MVC and Dynamic Data, that these are all just ASP.NET. Arguably ASP.NET Ajax and the Ajax Controls could be either another circle or part of the larger one.

I also showed ASP.NET+Dynamic Data that you'll be hearing more about at PDC and even more next year. You should feel free to use these subsystems as you like, mix and match, promote and ignore. Whatever makes you happy. All the ASP.NET core stuff like Authentication, Authorization, Session, Caching, etc, that all works in all of these subsystems because they are all ASP.NET.

Wow, that kind of sounded like a political speech! "Can't we all just get along? MVC and WebForms living together, with Dynamic Data by their side..."

Enjoy.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

T4 (Text Template Transformation Toolkit) Code Generation - Best Kept Visual Studio Secret

October 14, '08 Comments [30] Posted in ASP.NET | Programming | Tools
Sponsored By

Rob beat me to it. Blogging about T4 (the Text Template Transformation Toolkit) had been on my list literally for a year. He and I were singing its praises last night. Hopefully I can add something small to the conversation.

What's the story? Well, T4 is a code generator built right into Visual Studio. To be clear, you HAVE THIS NOW on your system…go play. Now's the time to introduce code generation to your company. If you're doing something twice or more, manually, in your company, generate it.

However, it's not deep-deep built in, because there's no item templates in File | New Item and there's no intellisense or syntax highlighting.

You don't need this, but if you want really get the most out of T4, first, head over to Clarius Consulting and get their "T4 Editor Community Edition." That'll get you some basic coloring. They have a pay version that gets you more if you want.

Now, go into Visual Studio and make a Console App (or any app) and add a Text File, but name it something with a .tt extension. You'll get a warning since it's a generator, that someone could generate evil. Click OK if you are cool with potential evil. ;)

Security Warning

imageNow, look in Solution Explorer at the .tt file. If you're using C#, you'll have a sub .cs file, or if you're using VB, a sub .vb file. That's the file that will hold the result of the generation. This is the same visual metaphor used to the express the template/generated file relationship with .designer files you've seen elsewhere in Visual Studio.

If you look in the Properties for the .tt file, you'll see it's using a CustomTool listed as the "TextTemplatingFileGenerator." This custom tool extensibility point is how things like XSD and WSDL code generators hook in to generate their artifacts.

T4 can generate any kind of text file, not just code. Whatever you like. You can use it in your projects, as above, or you can call T4 from the command-line.

Aside from Kzu and the folks at Clarius, Rob notes that Oleg Sych has a great collection of T4 resources. He's got some great Tutorials:

Here's some of the links from Oleg's blog.

Oleg also has a CodePlex project called T4 Toolbox that is a library of T4 templates that get added to File | New Item.

Also, check out Damien Guard's T4 templates that are a wholesale replacement of code that LINQ to SQL generates. Here's an example, where I use Damien's T4 templates against the sample Chinook Database.

image

Notice that I've named the .tt file the same as the .dbml, so Damian's code can find it. I also continue to let original LINQ to SQL generate it's .designer.cs file, but make that file's Build Action "None" so it's not ever compiled. That effectively puts Damian's code in charge.

Here's a screenshot showing a bit of Damian's T4 template using the syntax highlighting from the Clairus T4 Visual Studio free download. If I'd pay them, I'd get intellisense and syntax highlighting inside the code blocks also. It looks like a lot like ASP.NET Web Forms, or Velocity, or any templating language really. The code blocks are where your logic is and outside the codeblocks is the template for whatever you want to generate. Notice how Damien gets input and sets output. You have full control, you can read files off the file system, from with your project, etc. He sets the output extension also. I like to use .g.cs or .g.vb, myself. In this example his generated file is Chinook.generated.cs.

I particularly like Damien's example because he's swapping out parts of LINQ to SQL that he didn't like (the generated code) while keeping the part he did (the general mode, the designer, the dbml file.) If you don't like something, fix it.

Plus, it all works in Visual Studio without installing anything.

image

If you're doing Code Gen, or thinking about it, check out T4 as it's a great place to start. Also, search my blog for "Code Generation" as I was livign and breathing it with CodeSmith for the many years I worked at Corillian. Have fun!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Silverlight 2 is out!

October 14, '08 Comments [16] Posted in ASP.NET | ASP.NET Dynamic Data | ASP.NET MVC | PDC | Silverlight
Sponsored By

Bam. Silverlight 2 is out. There's the expected stuff, like the final SDK, Expression, and Silverlight tools:

And from Tim's blog:

And from ScottGu's blog, the Epic GuPost. But there's also http://www.eclipse4sl.org/. Yes, that means you can code Silverlight in Eclipse. Details and progress at the Eclipse Tools for Silverlight Blog. It'll be licensed under the EPL 1.0 License.

Love the free tools. You can also code Silverlight with the free Visual Web Developer Express, so you don't need to pay for a working development environment to try out Silverlight.

There's a bunch of new stuff in this, the Release of Silverlight 2. Check out Tim Heuer's blog for lots of good details on Controls, ADO.NET Data Services, Text Rendering improvements, and more. Also, there are (and will be more) videos, screencasts, samples and demos at my team's site at http://www.silverlight.net, so check it out.

Also, be watching the Silverlight Dynamic Languages SDK and CodePlex Site as I hope they'll update their stuff to the release of Silverlight very soon. It's fun to write IronRuby and have it running in a browser.

The Dynamic Languages SDK contains support for writing Ruby, Python, and JScript applications in the browser. However, since this project provides a bridge between Silverlight™ and the Dynamic Language Runtime (DLR), any language running on the DLR will be enabled to build Silverlight applications.

Also, if you're going to be at PDC, please come to my talk and see what Grant Archibald and I have been working on.

Microsoft .NET Framework: Overview and Applications for Babies

Join Scott Hanselman for this lots-of-code-minimal slides talk that walks through the sheer joy of building out a .NET Framework application with Visual Studio using many of the new advances in the .NET Framework 3.5SP1 and 4.0. We have a data layer with Entity Framework, use REST web services with WCF and ADO.NET Data Services, write an ASP.NET site for reporting using Dynamic Data and MVC. All the data will come from a WPF client application and a Silverlight application that the audience will run live! All this, plus it's an application that babies and toddlers will love!

Have fun!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.