Archive

Archive for November, 2007

Visual Studio 2008 goes RTM!

November 20, 2007 Comments off

OK, so I may have lied, but not by much!

Yesterday afternoon, while waiting for my MSDN number to be granted, I saw on MSDN that VS2008 went RTM!? I did finish the VS2008 Beta 2 download, but I never installed it. After waiting all day, I was finally able tog et my MSDN number from Microsoft and am currently downloading the VS2008 ISO file.? Tomorrow will be install day!

But since I am here, let me grouse a bit: why in the world does it take 24-72 hours for a couple of databases at Microsoft to share information?? I just can’t believe that there is this kind of delay.? One of the MSDN techs told me that it takes one day to get the data into the “Subscriber” database, and another to get it into the “Downloads” database. What gives? Microsoft of all companies shoul dbe able to make this sort of event automatic and practically instantaneous!? It just boggles the mind a little.

But hey, who cares!? I’ll soon be in .NET 3.5, and I hope you’ll join me there soon.

Categories: .NET 3.5, Visual Studio

Lies, Dang Lies, and the Developers Who Tell Them

November 19, 2007 Comments off

First thing I did this morning was subscribe to MSDN. It’s just a no-brainer since I’m typically going to buy the new development tools as soon as they surface anyway. I’m also in the process of putting together the specs for my new lap top. I was going to get one over a year ago, and then I said “I’ll wait for Vista”. Then I said “I’ll wait for Vista SP1”. Recently I’ve been saying “I’ll wait for Visual Studio 2008”. Well, I guess I’m not waiting for SP1, and VS2008 is just around the corner and may even be out by the time I get my new machine.

So I lied about SP1, and I also lied about waiting for VS2008 to RTM: I am downloading Beta2 now and I’ll be downloading Blend as soon as I can. I’m just so excited about these new features that I just can’t wait. And I have the perfect test project going on in house. On top of everything else, the timing for these releases couldn’t be better for us. So the next few days will probably be spent downloading and installing software.

Categories: .NET 3.5, Visual Studio

Post Conference Detox

November 16, 2007 Comments off

I am travelling home today, but in between flights I am checking into a few items. First of all, and yes I know most of you are saying “Duh!”, I am checking out MSDN Subscriptions for the first time. See, when we started learning .NET we did not know if it would stick for us not, so the idea of committing to a subscription just wasn’t in the cards. Now, two versions of VS later I think there is no question that we are in .NET to stay.

I’m still waiting for VS2008 to RTM before I download it, but this way I can do it without waiting for CDs or anything like that (not to mention all the other code I get access to). The Visual Studio Professional version of MSDN is $1199 with an annual renewal of $799. Again, a no brainer.

I’m also looking at Microsoft Expression Blend. Preview 2 is out, and supposedly when it goes RTM it will be available on MSDN as well. I think I will go ahead and download the free tria now that XAML makes a lot more sense to me.

So, I have begun detoxing and will be employing these new goodies as soon as possible.? There are a million things floating about in my head.? I actually fell asleep last night thinking of a new WPF layout for a small internal database I started last week. I haven’t been this excited about coding in a long time: thank you Microsoft!

Categories: .NET 3.5, C# 3.0, WPF

Live Blogging VSLive! Austin – Day 4

November 15, 2007 Comments off

9:00am:

Just about to start a Post-Conference workshop entitled “Advanced C#: Moving up to LINQ, VS2008, and .NET 3.5” by Richard Hale Shaw. Richard is extremely knowledgeable and has a tendency to go into deeper detail than anyone else, so this should prove to be a challenging class. Watch for updates throughout the day.

10:50am update:

Wow! I can’t wait to get my hands on VS2008 and .NET 3.5! Lots of stuff going on: we’ve been covering Custom Iterators again, which is pretty cool in its own right but has been around since 2.0. We’ve been covering them, though, in the context of Extension Methods which are HOT. Keep watching this site, you’ll see lots of stuff coming up in the future about Extension Methods.

I do have a couple quick bullets that came up:

  • DataContext is the key object type in LINQ
  • DataContext has a .Log method that will reveal the actual SQL that was executed
  • LINQ for SQL only works against SqlServer 2000+ : more evidence that we need to switch to SqlServer
  • Compiler Inference is very cool and reduces a lot of code. For instance: var allows the Compiler to infer the variable type from the return object and Anonymous Methods can be replaced with Lambda Expressions.
  • var will only work for local variables

1:30pm update:

Lambda Expressions are something else I’ll be exploring and posting about in the near future. Essentially, a Lambda Expression is a syntax method of creating Action<T> and Predicate<T> objects (there is another but I don’t recall its name). These objects are used by LINQ and some other constructs. Without Lambda expressions, these could be created using anonymous methods or by outsourcing the method call signature. Trust me, for most applications Lambda Expressions will be much better. There is too much about them to show how they work here, so here are a few bullets with the caveat that if you have not seen Lambda Expressions they won’t mean much for you:

  • Lambda Expressions can consume outer variables
  • Lambda Expressions can contain embedded code
  • Lambda Expressions can be used in LINQ or anywhere else that the return types are needed
  • Very readable, once you understand the syntax
  • Scope for Lambda variables is protected
  • Here is a sample line using a Lambda: .Filter( f => f.Length > fileSize )
  • In this case, “f” is a variable that lives only inside the (). “=>” is the Lambda Execution operator. “fileSize” is an outer variable (defined and populated elsewhere in the scope)

Other goodies:

  • Custom Iterators, and as such LINQ query objects, employ “Deferred Execution”. In other words, the actual IEnumerable<T> return value is not populated until the object is used (as opposed to when it is defined)
  • Extension Methods can be used in LINQ alongside the system defined actions
  • In VS2008, you can step through .NET Framework code in DEBUG (I believe there is an additional install to make this work)
  • LINQ can create Anonymous Types: in other words, the resulting IEnumerable<T> of a LINQ statement can be of a Type and structure that is not a defined type. This is very cool!
  • Properties in Anonymous Types can be based on Method call results
  • Properties in Anonymous Types can be named as desired
  • Properties in Anonymous Types can be other Complex Types

3:20pm update:

Lots and lots of details, and my seat is getting really sore, but I am here until the bitter end! Here are a few highlights from the last section:

  • LINQ sequences (Richard’s name for the resulting IEnumerable<T> collections) can be combined using .Concat() as long as the resulting Types are the same
  • This is even true for Anonymous Types: as long as they are defined exactly the same
  • LINQ can group results: this ends up in a IGroupedEnumerable that holds a set of Key Value pairs of the group key and IEnumerable<T>
  • The LINQ group feature can be based on an anonymous type (defined as part of the group statement)
  • Not LINQ related, but Richard mentioned something about using Partial classes as a way to protect custom code from Code Regeneration – great idea that also solves a problem I’ve had in my own CodeGen of ensuring that variables were defined as protected instead of private (since my system inherits from the generated abstract class) Update: I spoke with Richard after the workshop about employing this as a thin abstraction layer for DAL objects (Data Access Layer) and he suggested this would not be a good approach for that application.? And I may have misunderstood what he was saying in the first place, but I do think it led me to the idea that Partial classes could be a solution to this problem.

4:45pm update:

The last section was mostly about XLINQ (LINQ to XML), and we have plenty more to cover. The new XML classes are very easy to use and intuitive:

  • Essentially an OO wrapper around XML
  • XElement is the key class and represents an XML element
  • XElement has an “Elements” Collection of child XElement objects which is an IEnumerable<XElement>
  • This means that we should be able to use LINQ over the Elements collection

5:40pm update:

Down the home stretch. These are definitely long days, but well worth every minute.

I want to clarify something from above: the classes I mention for XML are XLINQ. These classes are found in System.Xml.Linq. After the XML is read in to these objects, then LINQ to Objects can be used as before. So XLINQ is LINQ, it just doesn’t look like the other flavors of LINQ.

Also, Richard showed a nice method of creating and storing much cleaner XML code based on defined classes behind the scenes. Then the Read and Write methods are abstracted out using Extension Methods and Generics. Very clean and powerful, and overall a fairly straight forward and simple approach.

Conclusions:

Well, this is the end of a great week. If you ever get a chance to attend one of these events, by all means you owe it to yourself to go. Here are the technologies I will be exploring in great detail as soon as I get back to the world:

  • LINQ – this is the KING of all the new MS technologies
  • WPF – simply awesome: a new paradigm in GUI design with great promise
  • SilverLight – a whole new web experience, both for developers and consumers
  • IIS 7.0 – looks substantially easier and more functional
  • Entity Data Model – not ready yet but will be soon and another paradigm shift
  • Visual Studio 2008 – should be RTMing this month. If you want to do any of the above, you’ve got to have the right tools.

I’m sure there’s more, but I am brain fried and butt dead. Check back often, I expect lots of new posts in the near future as I work through all this stuff.

Live Blogging VSLive! Austin – Day 3

November 14, 2007 Comments off

10:10am – Keynote:

The keynote this morning was “Take on your toughest challenges with Visual Studio 2008” by Sam Gavitt of Microsoft. The presentation was a practically oriented tour of Visual Studio 2008 ad its new features and capabilities. Some stuff we’ve already heard and seen, but this presentation was very solid. As usual, here are some highlight bullets:

  • VS is focused on three areas: User Experience, Collaboration, and Productivity.
  • Should be shipping via MSDN any day now – not to self: subscribe to MSDN!

Sam’s “Top Ten Reasons to Switch to Visual Studio 2008″ (with apologies to David Letterman):

  • WPF Integration and Interoperability
  • C# and VB language improvements
  • New HTML Designer
  • JavaScript Debugging
  • WCF/WF Integration
  • AJAX Integration
  • Unit Testing
  • Integrated Office Development
  • LINQ
  • Multi-Platform Targeting

These are definitely cool features, but I disagree on the last one. Multi-platform targeting (the ability to target code for any version of 2.0, 30, or 3.5) is a great feature, but it is not a reason to switch to VS: it the solution to a reason not to switch. LINQ is absolutely king: the absolutely best new language feature I’ve ever seen, period. Along with WPF and the promise of the Entity Data Model, LINQ represents a shift to Declarative programming. It will improve code readability, increase productivity, and result in significantly less code. If you really want to (and are stubborn) you can use LINQ in VS2005, but you get no real help from VS for using it. Switch to VS2008 and you get cool stuff like Intellisense and LINQ object creation. LINQ alone is worth the price of admission.

Web Application Stuff:

  • CSS Editing is greatly enhanced
  • CSS now has Intellisense
  • CSS Intellisense is also available in ASP.NET code
  • Tons of new file templates
  • JavaScript syntax highlighting
  • JavaScript Intellisense
  • JavaScript debugging
  • AJAX is SUPER easy in VS2008 – the demo blew me away

Windows Application Stuff:

Most of the stuff he talked about I’ve already posted a bunch on, namely WPF, VS, and Blend Coolness (but remember that Blend is not part of VS). He did briefly touch on WCF and WF integration, which I think is going to be valuable.

Office Integration Stuff:

OK, this is very very cool: Office development tools are now part of VS. You can add toolstrip buttons and features in Office products from your application. You can generate Office docs from your app. You can even create and embed your own Forms, including WPF stuff, in other Office apps. This sort of extension capabilities used to be a specialty in its own right and required specific training and tools: now anyone can do it, and it is slick.

11:37am update:

Just attended a session entitled “C#3.0 and LINQ Under-the-Hood” by Richard Hale Shaw. Richard has such a depth of knowledge that he is sometimes hard to follow, just because of the sheer amount of information he is capable of imparting. Truthfully, he didn’t talk much about LINQ at all, but rather he really got into the nitty gritty of the C# components that go into making LINQ possible.

Extension Methods:

A great technology that is going to be very useful, primarily for readability and productivity.

  • Add helper methods to classes you can’t extend
  • Operate on variables as thought he methods belonged to the actual class
  • The class name of the defining class is irrelevant, but it must be static and must be within appropriate scope
  • Extension methods must be defined as static
  • Obviously, a reference to the Extension method dll must be included in the consuming code
  • Intellisense indicates whether or not a method is an extension by prefacing it with (Extension)

Custom Iterators:

  • Lie at the heart of LINQ
  • Can be created by any method that returns IEnumerable, IEnumerable<T>, IEnumerator, or IEnumerator<T>
  • IEnumerator and IEnumerator<T> are preferred because IEnumerable is reserved for the primary Iterator of any given Collection
  • LINQ uses Deferred Execution based on Custom Iterators
  • Query does not hold data, but rather the mechanism for acquiring the data
  • Sequence methods (emplyed by LINQ) are built on Custom Iterators

Generic Delegates, Anonymous Methods, and Lambda Expressions:

  • Generic Delegates allow you to abstract and postpone the Action delegates until runtime
  • Anonymous delegates (a 2.0 technology) allow you to create and return methods on the fly: the compiler then generates the necessary code
  • Lambda expressions map to Generic Delegates to execute Anonymous Delegates in a more coder-friendly manner

12:45pm update:

“Using Visual Studio and the Expression Suite to Build Great User Experiences” by Denny Boynton.

A little bit of a misnomer: we really didn’t use Expression Studio, just Blend, but he did show something that was built using Expression video manipulation software (the name escapes me). He also did everything in a SilverLight application, which was good because it was the first one we’ve seen implemented in SilverLight.

I don’t have a lot of notes, basically we got to watch him work and start to get a feel for how the tools might be used in development. He never once edited XAML and only showed it to prove that you could get to it. He really segregated the Design work from the Development work, and the vision is starting to gel: this could really work. One of the other attendees pointed out that with these tools, you realistically could have separate designers. Maybe Microsoft is ahead of the game, predicting how it’s going to be rather than reacting to how it really is.

  • We really need a Rich User Experience (UX)
  • SilverLight is based on the RIA model (Rich Internet Application)
  • A lightweight plug in for IE, Firefox, Safari, and Opera (almost)
  • Runs on Windows, Mac OS X, and Linux (through “moonlight”)
  • Blend is really moving into the Designer Space
  • Designers are only limited by their imaginations: developers have always been limited by implementation capabilities
  • With XAML, those limitations are removed by completely separating the UI definition from the Code behind it
  • Expression Studio includes tools for Web design, Interactive design, Graphics Design, and Asset Management

3:10pm update:

Attended “IIS 7.0 for Web Developers” by Robert Boedigheimer. I need to preface all this with the statement that I am not an IIS person. I have limited experience with it, a few minor configs here and there on IIS 5.0 and 6.0, but nothing serious or production in nature. All that being said, based on the presentation and the reactions of those around me, IIS 7.0 is a great improvement over previous versions.

  • Broken up into a modular architecture
  • Uses pluggable components
  • Reduces attack surface and memory footprint
  • Configuration is all in XML
  • Installed modules are chosen in the configuration, so can be easily turned on and off without restarting IIS
  • Can be controlled from site to site (I think)
  • Modules are similar to ISAPI Extensions
  • Handlers are similar to ISAPI Filters
  • Custom Dialogs can be integrated into IIS Manager
  • Custom configurations are permissible
  • Configuration is independent for each website
  • You can write and apply .NET code to alter/extend IIS
  • Any request can fire .NET code (that you can develop!)
  • Modules are safer than filters because they are managed code BUT you still have to be wary of a performance impact (based on what you are asking the requests to do)
  • Header Details can be removed before a Response is sent – good for removing Server Identification information

.NET Integration:

It definitely appears that one of the big enhancements is the integration of custom .NET code. I can definitely see the power in being able to write my own methods to “do stuff” at any step in the process. Runs in one of two app pools: “Integrated” means that the .NET is in the Pipeline which “Classic” executes as ISAPI.

Forms Authentication:

In IIS 6.0, only ASP.NET files are protected. In IIS 7.0 all files can be protected using ASP.NET 2.0 Membership Providers for security. The authenticated user ID has been added to the log files. This non-ASP.NET file inclusion is disabled by default and must be enabled in the web.config file.

IIS Management:

  • appcmd.exe – Command line control
  • IIS Manager provides a GUI method
  • WMI Scripting is available
  • Can be done in custom .NET code by emplying the System.Web.Administration namespace

Built in Diagnostic Tools:

  • Traps and stores errors
  • Logs everything that happens
  • Failed requests are stored in an XML file
  • Can be configured to store all requests (or specific ones)

Run-time Status and Control:

You now have access to Internal Status information such as pools, processes, requests, etc. Accessible via all the above mentioned Management methods.

4:20pm update:

Just sat through a class on ASP.NET Architure by Paul Sheriff. A good overview of smart ideas for ASP developers. Not really an architecture, but lots of good common sense suggestions. Basically they boil down to these few suggestions:

  • Use CSS, Skins, Themes, and MasterPages
  • Wrap MS code that can cause you problems such as Sessions, Cache, Exceptions, ConfigurationManager, etc.
  • Create your own Base Page class and inherit all your pages from that base

CSS, Skins, Themes, and MasterPages:

  • CSS allows good separation of presentation and information
  • CSS promotes good structure (my note: this includes adding Syntactical value)
  • CSS is very flexible and is a well published web standard
  • CSS is cached on the client side and usually should be included as external files
  • SKins are like server-side CSS for ASP.NET controls
  • Themes group Skins and CSS together
  • Sites can have multiple skins and themes
  • Skins can be either Global (default) or Named (ID based)
  • Skins can be applied at runtime via the PreInit event
  • Themes are not set at runtime and cannot be established at the MasterPage level
  • There can be more than one MasterPage, but only one specified per page
  • MasterPages allow a consistent look and feel across an application
  • MasterPages can contain code
  • Subsequent pages use the Content are to deliver their information

Wrapping ASP.NET Constructs:

Wrappers are a powerful tool in many coding scenarios. In ASP.NET, wrapping such things as the Session variable array has many benefits:

  • Insulates code form future MicroSoft “enhancements”
  • Places code management in a single location
  • Allows variable initialization and implements default behaviors
  • Use this approach to wrap Exception management, Caching, ConfigurationManager, etc.

The last bit of advice is great: create a BasePage class that inherits from System.Web.UI.Page. Then have all of your Pages inherit from that class. This gives you global control over behaviors, can be used to implement security, provides consistency, etc. This is a rgeat idea and easy to implement, even after the fact.

The Last Session:

I went to a session on Distributed Data Application Design and Architecture, but I have to tell you I was pretty brain fried by then. The content was a little over my head, the presenter was very fast, and I really struggled to follow along, let along take notes for you guys. It’s probably for the best anyway as I doubt I would have made much sense.

See you tomorrow for the last day, I’m going to get some rest. And have some Tex-Mex food: benefits of visiting Texas!

Live Blogging VSLive! Austin – Day 2

November 13, 2007 Comments off

Keynote Address “Mapping your way through Microsoft’s Managed Data Access” – Michael Pizzo, Microsoft

10:30am:

The purpose of LINQ is to overcome some of the inherent flaws in Ad Hoc SQL data access from applications.

  • LINQ provides a set of language extensions
  • Integrates Query access as part of the application rather than implemented as Strings
  • Return values are in fact classes complete with strong typing rather than generic DataSets
  • Implements IQueryable to use LINQ over Collections
  • LINQ is available against DataSets, XML, and Entities as well as SQL

LINQ to SQL:

This is going to be the most important part of LINQ. This will essentially allow integration of the SQL Schema into usable objects in the Application.

  • Essentially a Strongly Typed SqlClient
  • Classes map to tables, views, SQL, and other Schema
  • Classes are generated by the LINQ Designer in VS2008 (saw a great demo of this)
  • Allows simple renaming of properties
  • Foreign Keys are implemented as Relationships
  • This means that additional table rows can be read in using Object syntax as opposed to additional SQL
  • Allows Type Inheritance for sub-Schema relationships
  • Can perform better than IDataReader
  • Can use StoredProcedures instead of SQL
  • Uses DataContext objects instead of IDbConnection – be sure to wrap in using statements for proper disposal
  • SQL Results become objects
  • Foreign Keys are available as Collections
  • DataContext has a .Log property for retrieving connection information
  • DataLoadOptions class allows finer control over when and how Related tables are read into the object

LINQ to DataSet:

  • DataSets still have value
  • Disconnected, serializable, etc.
  • LINQ makes filters, joins, projections, cross DataTable and cross Collection queries
  • Supports Typed and Untyped DataSets

ADO.NET Entity Framework:

The Entity Framework allows the Database Schema to be translated into complex Business objects.

  • Object Models are more complex than Schema’s rectangular storage model
  • Enables apps to work with higher level concepts such as relational navigation
  • Supports Type inheritance
  • Built over DataProviders
  • EntityClient is a declarative mapping of model to schema
  • LINQ can run over EntityClient
  • Produces Business objects
  • Provides Change tracking
  • Designers for this built into VS2008

The Future – Astoria:

  • Data Services over the web
  • LINQ/Query/CRUD over the web
  • Delivered as XML
  • Consumed over HTTP
  • LINQ can be used in Silverlight

11:40am update:

Attended “LING: What’s it all about?” by Ken Getz. I was really afraid that after the excellent keynote it would be repetitive, but NOT SO! I got so much out of it, and lots of it is not LINQ specific.

  • LINQ format is From… Where… OrderBy… Select
  • Select is always last, which really throws us SQL users
  • Select is last in order to properly support Intellisense (which unfortunately really only works in VB for now)
  • The From clause includes an item handle and indicates a Data Source
  • Uses implicit variable declarations – in both VB and C#, you can get an object variable to define it’s own type based on return value

Extensions Methods:

  • Add new methods to existing classes without access to the source code
  • Must be Public
  • Must accept a parameter of the type you wish to extend
  • In C#, it must be defined in a Static Class
  • C# uses the this keyword to indicate that this is an extension method
  • Can be used as a Static Class Method or an Instance method

Automatic Properties:

  • For properties that only expose an internal variable, the need to define and use that variable is no longer required
  • Does not require Constructors to update them, but it opens the problem of initializing properties that are not included in any constructor
  • SO – a Constructor can be used that does not actually exist: properties can be indicated on the new statement like so: MyClass c = new MyClass() {prop1 = value, prop2 = value};
  • Which means you can use a Constructor that essentially does not exist

LINQ for Objects:

  • Great for analyzing Collections
  • Takes advantage of Extensions Methods
  • Query class has many built in extensions:Any, All, Average, Where, Concat, Contains, Convert, Count, Distinct, Except, etc. etc.
  • Can use functions in Select clause
  • Functions must supply an expression (called “Lambda Expressions”)
  • Can include Anonymous Methods
  • Expressions can only have one item in and one item out
  • There can only be one expression on a function
  • Example: foreach(Actor a in Actors.Where(x => x.BirthDate.Month == 9))
  • “x” above is the individual object notation, “=>” indicates execute this comparison
  • Can use Anonymous Types – essentially, these are objects created on the fly (like creating columns in SQL Select) and added as a new Type to the resulting objects in the resulting Collection
  • Example: “Select new {NameOfProperty = actor.LastName + “, ” + actor.FirstName}”
  • Use Skip and Take to paginate different rows from within a collection

1:40pm update:

Attended “Styles and Data Templates” given by Bill Hollis. A good follow on from where we left off yesterday, the class got into some of the finer aspects of Templates and Styles. The more I see this stuff, the more I want to smack my head: I’ve had 3.0 installed since last year’s conference, but I’ve never forced myself to spend some time learning any of it. I look at it now and wish I had. But in truth this is the right time to be learning about it: with VS2008 and Blend, the technology is finally beginning to catch up with the theory. This is also the right time for my company given that we are just entering the development stage of a new suite of Applications. But enough rambling, on to the highlights:

  • Styles can be changed on the fly for any Element using the FindResource() method
  • TargetType is used to specify a style for all Elements of the same type en masse (within subsequent scope). This can be applied at any level, where ever a Resource can be defined (which is anywhere)
  • TargetType can only be applied to a single Type (this is not true for named Styles) – it cannot be found and applied to children of a different type
  • You can develop and import ResourceDictionaries to store Resources externally – think reuse, like importing CSS files
  • Styles support inheritance, so you can pull from a common parent and apply additional styles or override styles for specific elements
  • Style precedence is deermined from the element up, so if the element describes and style, then it overrides any named styles or TargetTypes
  • Inheritance accomplished by using “BasedOn={StaticResource parentStyleName}” on the Style definition
  • Styles can be tied to properties (and Events in WPF have reflecting properties, so by extension they can be tied to Events also)
  • DataBinding can be done at the Control or Container level, so you can specify a single Binding for an entire DataTemplate or Panel and then use it in child Elements
  • DataTemplate is like a mini-Window defined in XAML
  • DataTemplate places content in a ContentControl
  • The root Element is usuallya Panel, but can be anything
  • Anything goes regarding layout with a DataTemplate
  • Blend has a DataTemplate editor (why doesn’t VS have some of this stuff?)
  • A DataTemplate can have Triggers that change aspects of its display based on events and properties
  • They can be applied base don individual properties to any level Element

I have not seen it demonstrated, but after the presentation Billy confirmed that he has seen Vista Gadgets built on WPF. Man, the possibilities here are unbelievable. WPF really is the first GUI paradigm shift we’ve since the GUI was created.

3:10pm update – VS2008 Overview:

  • VS is a shell that hosts other Components
  • Because 3.0 and 3.5 build on 2.0, there is distinct support for each of these three frameworks in VS2008
  • 2008 Solution files are a little different than 2005
  • ASP.NET Web Applicaiton projects have AJAX support built in
  • Intellisense can be hidden by holding the CTRL key down (well, not really hidden, but it becomes translucent)
  • Intellisense is expanded and improved in VS2008: supports LINQ
  • JavaScript Debugging – use F9 to set breakpoints
  • Complete access to the Document object tree in debug
  • There is an ImmediateWindow for making and testing on the fly Script changes
  • WCF support is built in to VS2008
  • WPF Designer is built in to VS2008 (but investigate Blend)
  • WPF anchoring is controlled inside the designer window, not the properties grid
  • ClickOnce support enhaned
  • VS2008 also has XSLT debugging
  • XSLT breakpoints can be set in both theXSLT and the Data Source file
  • Web Apps have a Split Screen designer option
  • Support has been added for nested Master Pages

4:20pm update:

Attended a class on “Expression Blend for Developers” by Billy Hollis. Not really a lot of new information, but it did go into more detail and show some more hands on type use of Blend.

  • Blend is part of the Expression Suite, but Blend is included in MSDN. The rest of the suite is really meant for Graphics Designers.
  • Blend is the preferred tool for developing WPF and SilverLight UI.
  • Blend and Visual Studio share the same projects, so when you create a project in Blend you must select the Framework and Language targets even though you cannot develop code in Blend.
  • Blend is designed for Wide Format screens, so that will grant a better user experience than traditional aspect ratios.
  • Blend will execute code written in VS.
  • Grid is the default root element of any new WPF app in Blend, but it can be changed to other Panel types.
  • Grid Columns are better designed in VS than in Blend: the properties grid in VS makes setting column and row information easier while Blend only allows you to approximate sizes by eye on the design surface.
  • Otherwise, Blend is the superior tool for the UI development.
  • XAML editing in Blend does not have Intellisense (but VS does)
  • Blend has visual tools for creating DataTemplates and Styles and can save them as Resources, either for the Application, Windows, or a ResourceDictionary
  • Blend can set up DataBinding using a drop and drag technique

After all I’ve seen, between WPF and Blend, C# 3.5 and LINQ, all I can say is that I am going to have a lot of fun over the next few months.

Post session update:

The last session of the day was on the new Entity Data Model.? The keynote this morning had already hit most of the highlights, but in this session we actually got to see some of the tools and results.? And again, I am very impressed.? The technology is not ready for prime time (which is fitting since it won’t be released until spring), but it has great promise.? The point of it all is to be able to further abstract the database schema from the objects that use it.? EDM is all about abstraction: data mapping rules stored in XML files are how the complexity is managed.

Basically, the objects are defined as you would actually use them, with no regard to how they relate to database schema.? The framework then generates “go between” code to handle CRUD operations.? LINQ is used heavily to interface with the resulting Entities.? This will definitely be a technology to watch.? Here are some final bullets:

  • Can be done in VS2008, but you need to load the ADO.NET Entity Framework and tools separately
  • Provides graphical modeling of databases and Entities
  • The resulting Entities are then used in lieu of the actual DB connection (using the ADO.NET disconnected model).? In other words, you treat data like objects
  • One Entity can update multiple tables seamlessly, and the schema relationships are maintained
  • If the schema changes, must rerun the wizard to regenerate the new Entities. (unless you are a masochist who likes to do things manually)

More to come tomorrow.? Whew, these days can really wear you out!

Categories: .NET 3.5, C# 3.0, LINQ, WPF

Live Blogging VSLive! Austin – Day 1

November 12, 2007 Comments off

9 am:

Today, VSLive! Austin begins with a session by Billy Hollis entitled “Maximizing WPF & Silverlight”. I’ll be updating this post throughout the day with interesting tidbits from the presentation. The problem is that there is no power in the room, so I can only run for so long before I need a recharge. If I have any complaints about VSLive!, this is it: know your audience – we need power!

I’ve been to several of Billy’s presentations in the past, and he is a real GUI Guru, so I look forward to today’s presentation. If Silverlight promises as delivered, it will finally be the technology to realize the goals of Java Applets and Flash. Should be fun!

9:48am update:

  • WPF is hard technology to learn: it is not unusual for developers to flounder for several weeks or even months while in the learning process
  • WPF is Vector based, rather than Bitmap based. This should bring the end of developing for specific screen resolutions
  • WPF is optimized for integrated media
  • Silverlight is a subset of WPF. Small install, runs in a browser not unlike Flash. Cross-platform capable. As such, it cannot do everything WPF can, such as 3D.
  • For more robust web apps, WPF can be run inside the browser. This requires WPF to be installed on the machine, and so it will only work on Windows, and currently only in IE (although other browser support on Windows is expected). If you see a web page with an “.xbap” extension, this is WPF running a browser.
  • Having the same skill set from Silverlight to full WPF GUIs allows developers to leverage the same skills to do many different UIs
  • Silverlight 1.0 is limited to JavaScript: no code-behind capabilities. Billy says that writing rich code in JavaScript is like “frosting a cake with a Ping-Pong paddle. It can be done but it ain’t pretty!”
  • Silverlight 1.1 (now in testing) will allow code-behind and will distribute a mini-CLR. This means you can write and execute C# code in ANY browser on ANY platform.
  • WPF has a greatly enhanced ListBox control: complete control over the graphics and implementation of each individual item. Allows dynamic formatting and sizing.
  • WPF and XAML are a move towards declarative programming. Simply declare what you want, instead of defining how to create it, and the system does the rest.

10:07am update:

  • XAML is very friendly for Code Generation – Billy showed a tool he wrote in a few minutes similar to my own PropertyBuilder (see Free Code)
  • A quick note: the new language versions (like VB9) have embedded XML tools and object
  • Designing XAML: you can use either Visual Studio or Expression Blend
  • VS is designed for developers – gives full access to code but cannot do all the design work, such as gradients
  • Blend is designed for Designers: great graphics tools, but no access to code
  • Blend can execute code that is already present
  • The two can be used simultaneously: both open and use the same .proj files – a change in one will be detected and prompted in the other
  • Blend XAML does not have Intellisense, but VS does
  • Blend is a separate license, but is part of an MSDN subscription
  • CONCLUSION: use Blend to develop the XAML, and VS to edit it manually and write code

10:50am update:

  • WPF Window class is the root visual element
  • Very much like the Form class: same properties and events
  • Managed by the Application class as part of Window collection

A good question was asked about the future of Windows Forms. This was Billy’s response:

  • Forms are not going anywhere: will be supported for a long time to come
  • BUT there will be no significant enhancements: all future development will be for WPF
  • WPF is more expensive to develop for right now: more resources, more time, high learning curve
  • Eventually, WPF will be as easy or easier than Forms
  • WPF does not make Forms obsolete
  • New applications should be designed in such a fashion that Forms can be replaced by WPF (good separation of UI and Code) or developed for WPF up front (biting the bullet)

WPF Elements:

  • Element is the catch-all term for everything in WPF, like we treat Control today in Forms
  • A Control is anything that interfaces with the User: buttons, checkboxes, etc.
  • A Container is an Element that contains other elements
  • Like Panel (which is an abstract class in WPF) – used for layout and management: there are four basic Panels – StackPanel, Canvas, Grid, and DockPanel – all used for layout
  • Or Decorator (such as Borders and the like)
  • Item Controls – lists of other elements
  • There is no DataGrid in WPF
  • Containers have Child element collections
  • Controls are limited to a single Content property
  • Content can be ANY .Net object – including Containers
  • So any Control can be essentially anything
  • Non-WPF objects are displayed as their .ToString() implementation

1:30pm update:

Getting back from lunch, here is a quick update from the last session.

  • Content items can be very complex: one example would be making the content of a tooltip a video box
  • Buttons traditionally fire their click event upon release, but WPF introduces the ClickMode Enumerator: release, press, and hover.
  • TextBlock is the most lightweight text control, even more so than Label (it is missing a lot of events, properties, and methods)
  • Menus and Toolbars are ItemControls, managing a list of other controls
  • Measurement Units replace pixels – they are device independent, theoretical units – their actual size is relative to system DPI settings
  • The Canvas panel type uses absolute positioning and appears to make the most sense to typical Form developers – don’t fall into the trap! It should be used sparingly sense it does not handle Resizing (one of the main goals of WPF)
  • There is no Forms to WPF conversion
  • Forms can be used in WPF
  • Silverlight 1.0 only supports the Canvas panel type, but later versions are supposed to incorporate other panels
  • In WPF all Colors become Brushes – this means that whereever there is Color, you can use Gradients, images, shapes, textures, etc.
  • NOTE: the new language versions support “Relaxed Delegates”. This means you do not need to define event args for event signatures if they are not needed.

Data Binding:

  • Data Binding in WPF is very good
  • Blend has some tools for assigning Data Binding
  • VS does NOT have any tools for Data Binding, you must code the XAML by hand
  • XAML uses “Markup Expressions” for variable items such as Data Binding – there is no Intellisense in Markup Expressions
  • Elements may have multiple bindings for different properties
  • Bindings are defined as Data Context properties: when data binding occurs, the elementsearches up the tree until it finds the first Data Context.
  • This does NOT mean it searches for matching properties! It just uses the first one it finds: failing to find one results in a Silent Failure, so nothing happens and there is no Exception to catch.

6:15pm update (post class):

The wireless quit working for a while, and then I ran out of power, so I missed the last two updates.

More on Data Binding:

  • Anything that implements IList can be bound to a ListBox
  • Data Binding can come from XML, ADO.NET objects like DataSet and DataTable, or a Resource List defined in XAML
  • WPF Element properties can be bound to other Elements Properties: this is a potentially very cool feature. The example Billy showed was binding a TextBlock’s FontSize property to a Slider control’s Value. Move the Slider and the Font Size of the TextBlock changes automatically

Some Miscellaneous points:

  • VS2008 Properties window has no ABC sort. I hope this is fixed in the GA version because it is awful to constantly scan the window looking for the correct property
  • As XML, XAML is case sensitive, which really bothers VB developers

XBAPS – some more on using Silverlight or WPF via a browser:

  • Like any web page, XBAPS run in a security sandbox
  • Apps delivered by the server: Software-as-a-Service
  • Can store small amounts of information in Isolated Storage. Good for configuration and cacheing.
  • Requires the .NET Framework 3.0+ – Silverlight does not.
  • XBAP takes over the entire browser window – Silverlight does not.
  • ASP.NET can deploy Silverlight components like Flash.
  • Silverlight is installed in the browser as a plug-in.

Resources – A crucial part of WPF used to define reusable items:

  • XAML can contain declared resources
  • Used partially for styling
  • Can be ANY .NET object,but is usually a WPF object
  • The name of the resource is the key in a Resources Collection
  • Can be defined at any level of the XAML: application, window, grid, panel, etc.
  • Employed like stylesheets
  • When looking for a match, walks up the tree until it finds the first one

Data Templates – a way to define layout and binding templates:

  • Helps with the separation of code and UI
  • Data should not care about how it is displayed
  • The UIElement is in charge of the display
  • A data template is used to layout data in a display
  • Data Template elements can be data bound to object properties or other information
  • Defined as a Resource
  • Templates can contain other Elements such as Panels, TextBoxes, Images, etc.
  • Template assignments can be changed dynamically: apply different templates based on different states

Animation – not just “cartoonish” or movement, animation means “changing visual properties over time”, such as color, opacity, size, position, etc.:

  • Has good and bad uses
  • Good animation should be a metaphor for a real world experience (opening a folder, for instance)
  • Real world movement is more natural than something just appearing or disappearing
  • Fading in and out “feels” more comfortable and natural
  • Establish a Path or Storyboard (use Path for movement)
  • Bind animation to an appropriate property
  • Animation classes are used to execute
  • There are different Animation classes for each data type, like DoubleAnimation for doubles
  • Namespace: System.Windows.Media.Animation

Media:

  • MediaPlayer wraps the Windows Media Player
  • MediaElement wraps MediaPlayer in XAML
  • EventTriggers respond to buttons
  • MediaElement can be the Content for any Control – you can effectively put video anywhere
  • Media can be used to create a VisualBrush

Transforms – used to alter shapes and sizes of graphics

  • A Transform is a system that maps a coordinate space to a different coordinate space
  • Unlike GDI+, you can simply declare Transforms in WPF and they “just happen”
  • TranslateTransform is used to offset hte starting coordinate
  • There areTransforms for Scaling, Skewing, and Rotating
  • MatrixTransform is used to apply multiple Transforms
  • RenderTransform will apply the transform withoutupdating the Layout
  • LayoutTransform will adjust the WPF layout to accomadate the Transform

Styles – like CSS, styles are used to change the look of Elements:

  • Declared as a StaticResource
  • Allows you to define multiple properties simultaneously
  • Styles can be assigned at any level or globally for a type
  • Styles can inherit from other styles using the BasedOn attribute

Ink – add Ink capabilities anywhere:

  • Bolted on to Windows Forms, but built in to WPF
  • Use an InkCanvas and set the background to any element
  • You can Ink over anything, including streaming video
  • Ink also has Recognition capabilities via the System.Windoes.Ink.InkAnalyzer class.

Whew!? There is more I could add, but what a day!? I think these pre and post conference seminars are the best part of VSLive!? See you tomorrow!

Categories: .NET 3.5, Silverlight

FilmStrip Control

November 11, 2007 Comments off

One of the current projects I am working on is Image Management software for one of our legacy government applications. Basically, JPG images are stored on a Windows server and our iSeries machine issues local PC calls (using STRPCCMD) to initiate the image manager. The manager then finds and displays all the images associated with the particular database record. The details are irrelevant to this post, but each database record can have up to 99 images associated with it, all organized and retrieved by naming conventions, so managing these images is not a trivial matter.

The original version of this software was written in VB a decade ago (probably VB4 or VB5). It was sufficient but unpleasant so about 5 years ago the company contracted with a local developer to rewrite the application, which he did … in FoxPro. It is also functionally but unpleasant to use, and so I find myself looking at a good target for a .NET rewrite!

One of the problems with the current version of the software is you can only see one image at a time. Unfortunately, this means you have to view each one to find the correct image, a real annoyance when dealing with large numbers of images. So my solution is to incorporate a FilmStrip control to view and scroll through a list of thumbnail images. I also, naively, thought this would be a fairly standard control, but alas it does not exist in the MS toolbox. This means creating one of my own, not a task I relish. I haven’t had lots of luck with User Controls or drawing my own. I find it tedious and frustrating: in other words, it just isn’t my cup of tea.

Fortunately, we have Google. A quick search for “C# FilmStrip” turned up this gem on CodeProject (one of my favorite sites). Most of the nitty gritty and the solution for my project came directly from that version, so I want to give full credit. The example was an excellent starting point, but I have, naturally, added some goodies of my own.

First of all, the original version required the user to pass the path string to the AddPicture method. Instead, I wanted to make this Control a little more portable: since it deals primarily with a collection of Images, I decided to have the FilmStrip work with Image objects and let the consuming code worry about pathing. The original also provides a way to print labels for the images, but they are based solely on a parsing of the image name. Instead, my version allows the user to assign a label to associate with the image. These are both done through a custom Struct named PictureInfo. Currently the Struct is pretty limited with just these two properties, but it could be easily expanded to contain any associated data. Also, I wanted to add some way of selecting and identifying one of the Images (PictureBoxes), so I added code to track which PictureBox is currently active and I change the BorderStyle of the active PictureBox to identify it as such.

Finally, I need the FilmStrip to report to the consuming software when the selected PictureBox changes, so I added an ActivePictureBoxChangedEvent, complete with its own ActivePictureBoxChangedEventArgs class that exposes the PictureInfo object of the newly selected PictureBox. By exposing the PictureInfo object, the consumer has direct access to the original image and whatever other information gets added to the PictureInfo struct.

The FilmStrip dynamically sets the size of its child PictureBox controls based on the size of the FilmStrip control and even calculates and applies the correct aspect ratio to the thumbnail based on the aspect ratio of the actual image. The full image is stored in the PictureInfo Struct so it can be reclaimed at anytime. I used a Generic Dictionary<PictureBox, PictureInfo> list to keep the PictureBox controls associated with the correct PictureInfo instance.

The public DisplayImages method can be used: just monitor the Resize event and call it accordingly.

Possible improvements:

  • Replace the scroll bar with navigation buttons.
  • Display the images as an automatically wrapping collection, always center the active image in the display.
  • Make the active image a larger size than the other images.
  • Add the ability to set the active picture box border color and/or style.

I hope you like this Control. Download it and try it today. Let me know what you think!

IBM iSeries .NET Managed Provider UPDATE

November 1, 2007 Comments off

One of the most popular posts on this site is about the iSeries .NET Managed Provider. In that post, I discussed a problem with an ObjectDisposedException being thrown at the end of every program that connects to a System i machine. The PTF solution promises to correct the problem on V5R3 machines and that the problem is automatically fixed on V5R4.

In the immortal words of Carol Kane, playing Miracle Max’s wife in The Princess Bride: “Liar! Li-Ar!” (I hope there are some TPB fans out there!)

If you hadn’t guessed, we tried it and it did not work. We upgraded one of our machines to V5R4 last week and upgraded the PC running iSeries Access to the V5R4 version to no avail: the error persists. My Business Partner is supposed to be looking into it, by which I mean that I need to tell him what PTFs I want. Frankly, I am looking at alternative solutions.

One possibility is to consider third party providers, Data Direct in particular. Data Direct’s Connect for ADO.NET product promises integration with every version of DB2 (including System i), Sybase, Oracle, and of course SQL Server. I have not looked at the code yet, but I was informed during one of our several phone conversations that the interface is a little different than strict ADO.NET, but it is consistent across all of Data Direct’s providers. The best news is that the providers are completely distributable along with our product if we purchase an OEM license. This means that unlike IBM’s solution which requires the customer to have and install at least some portion of iSeries Access V5R3 or higher, Data Direct’s solution does not require any additional installations. The bad news is that an OEM license would be very expensive. While they will tailor it to our company, I fear that it will ultimately cost too much. The license is naturally an annual fee, but once the company profits exceed an unspecified amount, the license fee becomes a percentage of the company’s revenues. All in all not a warm and fuzzy proposition.

Another option, that is contrary to all our previously stated goals, is to simply develop our new product line for SQL Server only. The good news about this idea is that all the tools and examples for rapid development take advantage of Visual Studio and .NET’s tight integration with SQL Server. I do think that the products would be easier to develop in this fashion. Another good thing is that if we design the architecture properly, we could make the switch to a database agnostic approach later without a lot of rework.

And the answer: I don’t know. In an effort to simply move forward, I am inclined to only consider SQL Server at the moment. I think this will relieve some initial headaches and speed development. But to appease our existing customer base, not to mention at least one of the company owners, we will ultimately have to address iSeries DB2 support.

Categories: .NET 2.0