Birds of a Feather (BOF) at PDC 2009

I’m excited to announce that I will be leading a BOF session at PDC 2009!  The topic is related to something we discussed at the Denver Visual Studio User Group a couple months ago.  At that meeting we talked about the issue of deciding on a front end technology for web applications.  There are a bunch of technologies out there and deciding on the right one can be overwhelming.  The nice thing about this topic is there really is not a right or wrong answer, which makes it perfect for a BOF session.  If you are going to PDC be sure to attend this session so we can discuss the topic as a community.  Here is a link to the details:

http://www.pdcbof.com/post/203606737/bof-session-should-i-use-silverlight-mvc-or-web

See you there!

.NET Rx Framework – A New Way To Handle Asynchronous Programming

I literally just read this article and wanted to get it out here for people to read.  This article outlines some of the comments made by some of the people behind the technology.  Give it a quick read and go do some more research.  Here is a Bing search I did and there is a bunch of good info on it.  I don’t think it is ready for production currently.  However, I believe this is going to be a big part of VS 2010 and how we deal with the asynchronous nature of programming to services over a network.

Microsoft AJAX CDN (Plus jQuery)

I just saw this today and it looks cool.  Let me give you the high level overview and then you can go to Scott Guthrie’s detailed post.  A while back I started to use jQuery to help with all my JavaScript coding.  I really like it.  Even if you don’t use the really advanced features it is a huge help just selecting and operating on elements client side.  If you want some more info on jQuery just search the web and you will find tons of good documentation out there on the blogosphere.

So, one of the hassles with jQuery is that you have to include the libraries in script tags on your page in order to use them.  This is not a huge deal, but it can be a pain if you want to use the libraries in multiple projects and maintain one central version of the jQuery libraries.  That is were the Microsoft AJAX CDN comes into play.  It is a Microsoft hosted version of both the AJAX libraries and the jQuery libraries.  So, you can point to a Microsoft URL and bring in these libraries.  This will find the location that is closest to your user and bring down the libraries from the cache on that server.  Should be a much faster solution for everyone.  Check out the details on Scott Guthrie’s blog here.

More on C# Dynamic Programming

Just wanted to share this article on C# dynamic programming from DevFusion.  It explains the difference between anonymous types and dynamic programming.  Don’t get too caught up on the opinions of the author Mike Jones.  Whether you agree with him or not this is a great explanation of using the dynamic keyword in C#.

Enjoy!

Silverlight 3 Jumpstart Book

Just wanted to let everyone know that my employers and friends Dave and Julie Yack have done it again.  They have published another book.  This one is a 200 page jumpstart to the recently released Silverlight 3.  I helped do some tech editing of the book the last couple weeks and I can say it is really good for getting started with Silverlight.  Read more about the release on Julie’s blog here.  You can also get some more details about the book at the books website http://silverlightjumpstart.com/Default.aspx or on Amazon.

Happy reading….

Dynamic Programming with C# 4.0

Yesterday Joe Mayo talked to the South Colorado .NET User Group about the new features of C# 4.0.  The most interesting change is the addition of the “dynamic” datatype.  This datatype allows developers to declare a variable that is not actually typed until runtime.  This is different than the “var” keyword which actually types the variable using the return value from the right side of the equals sign.  Let’s take a look at a quick example:

   1: private void Main()
   2:         {
   3:             Dog thisDog = new Dog();
   4:             AnimalSpeak(thisDog);
   5:  
   6:             Cat thisCat = new Cat();
   7:             AnimalSpeak(thisCat);
   8:  
   9:             Frog thisFrog = new Frog();
  10:             AnimalSpeak(thisFrog);
  11:  
  12:             Bird thisBird = new Bird();
  13:             AnimalSpeak(thisBird);
  14:         }
  15:  
  16:         private void AnimalSpeak(dynamic Animal)
  17:         {
  18:             Animal.Speak();
  19:         }
Notice on line 16 the parameter uses the dynamic datatype.  This allows us pass in any object and try to call the Speak method.  Also take notice we are not using an interface to ensure there is a Speak method on the object.  So, we lose the benefits of strong typing and if the object passed in does not contain a Speak method we get a run time error. 

The dynamic datatype is very powerful, especially when it comes to dealing with COM interop.  It also will aid test driven development (TDD) by allowing developers to write unit tests without worrying about the actual implementation of the objects they are testing until after the tests are written.  Again very powerful.

However, with great power comes great responsibility.

I feel that there are a couple issues with dynamic programming.  It seams we have come full circle with .NET.  I remember when .NET first came out and everyone was promoting type safety as a huge benefit.  Now with dynamic programming we can bypass type safety and just wing it. One problem I have with this is that the errors are runtime errors.  So, for example lets say we are accessing a COM object dynamically.  In our dev environment we have a the new version of the COM object that supports some new functionality we are using.  If we move the application to test or prod and forget to upgrade the COM object, the application may start and run without a problem but will bomb at runtime whenever a user tries to access that one section of our app that is using the new functionality.  To me this puts too much emphasis on QA testing when the application still compiles but may bomb at runtime.

Another disadvantage of dynamic programming is the lack of intellisense.  If you declare the variable as dynamic then intellisense will not work.  Again, this opens up the issue of misspelling some of the properties or methods that will not get caught until runtime.  I really like intellisense so I will not use dynamic unless it is the last option.

My fear is that many developers will get lazy with dynamic programming and use it in the wrong situations.  Using it as a replacement for using interfaces or good old fashion reflection may cause more runtime issues that slip past testing and hit production users.  Some developers may see that as job security.  I see it as a sure fire way to lose customers.

Silverlight 3 and IE 8 Compatibility – Silverlight Control Not Sizing

I ran into an interesting issue with IE 8 and Silverlight 3 today.  We recently switched over to Silverlight 3 to start testing for the upcoming upgrade.  The Silverlight 3 conversion went pretty smooth and it all worked in the test website we are using in the Silverlight solution.  However, once we moved it to QA the sizing of the ASP.NET Silverlight control was not correct.  It kept cutting the Silverlight stuff short.  Not sure what the deal was, but I was able to fix it by wrapping the ASP.NET Silverlight Control in a div tag.  Wraping the control with this div will get it working but I’m not sure if it is a long term fix.

<div style="position:absolute;top:0px;left:0px;right:0px;bottom:0px;">

</div>

SQL Server and .NET Virtual Conferences

I am happy to say I am presenting at the Spring ‘09 SSWUG.ORG .NET vConference on April 22, 23, 24.  I recorded my sessions earlier and I’m please with the results.  If you are not familiar with the vConference format you can get a 10 minute sample of one of my presentations here.  The cost of the conference is only $125 and since it is a virtual conference there are no additional expenses.  There really is some great content presented by outstanding presenters.  Here is the link to check out all the SSWUG vConferences going on:

https://www.vconferenceonline.com/upcoming.asp

I also wanted to point out a free event that is going on Friday, April 17th.  Here is the link to the free event:

https://www.vconferenceonline.com/shows/spring09/sql/s09event.asp

I will keep this blog updated with my content and slides once the conference begins.

Extending the ADO.NET Entity Framework

Last night I gave a presentation on the ADO.NET Entity Framework at the Denver Visual Studio User Group.  It was a great discussion and the questions from the audience helped me tell the story I was trying to tell.  That story is that the Entity Framework is a great data access tool.  It’s extendable and in turn flexible enough to meet the needs of the small point solutions to the enterprise caliber solutions.  What I really like about it is the ability to start simple.  Let’s get a solution up and running and then go back and extend\refactor certain areas to improve the architecture and\or performance.  That’s not saying we shouldn’t do some design work up front, but let’s start by getting a solid solution built and then add on features and improvements in the future. 

Sometimes I think architects focus too much on creating the perfect architecture instead of creating a flexible one.  The solution just needs to work given the current requirements.  Beyond that, it also needs to be flexible so it can change when new requirements and features get defined.  EF lends itself very well to flexibility and extensibility.

The zip file below contains the final solution.  That solution has all the extensions we did to the context as well as the entities in the context.  It also includes a basis for a validation framework.  The validation framework could use some tweeks to make it better.  I leave that to you and your creative minds. 

The zip file also contains a SQL script that will quickly and easily create the sample DB for you.  Both the schema and the data.  All you need to do is change the location of the DB file (.mdf) and the log file (.ldf) in order to run the script.  Once you get the DB created you will have to change the server name in the connection string located in the web.config.  After that everything should run great.  Here is the zip:

EFDemoes.zip

I hope that you enjoyed the talk.  If you would like the step by step guide to creating the initial model and setting up the inheritance please visit Rob Bagby’s blog of EF.

XRM Taking Off

At Colorado Technology Consultants (CTC) we do quite a bit of work with MS Dynamics CRM.  One of things Julie and David Yack are big on is the concept of XRM.  If you are not familiar with it, it extends the Customer Relationship Management side of MS CRM to any kind of Line of Business application.  MS CRM is a very customizable product and can be extended to be used for many non CRM type applications.

That being said CTC is kind of the XRM gurus right now.  Dave’s book on the subject is actually being used on MSDN in some places as reference material.  You can purchase the entire book, including a usable .NET framework that comes ready to use with the book, here.  Julie is starting up an XRM Virtual User Group that will consist of monthly Live Meetings related to the XRM space.  The user group site is actually built on top of MS CRM Live and hosted on Azure in the cloud.  Please visit the site to check out an impressive display of XRM and to register with the group.

XRM is becoming one of the hot Dynamic products.  So, you next step is to attend the XRM Virtual User Group meetings and learn how to use XRM to solve your software needs.

Iterating Through a Collection Using Reflection

I ran into an issue today using reflection.  I was getting properties on a object using the following code:

   1: Type argsType = args.GetType();
   2: PropertyInfo piResults = argsType.GetProperty("Result");
   3: object result = piResults.GetValue(args, null);

This works great if the object you are trying to retrieve is just a simple object.  However, what if the object in question is a collection of some sort?  This does not work because the results of type object are useless.  The key to solving this issue is to use the IEnumerable interface.  Here is the code to solve my issue:

   1: Type argsType = args.GetType();
   2: PropertyInfo piMessageList = argsType.GetProperty("Result");
   3:  
   4: IEnumerable Messages = (IEnumerable)piMessageList.GetValue(args, null);
   5:  
   6: Type objType;
   7: PropertyInfo objResults;
   8: foreach (object thisMsg in Messages)
   9: {
  10:     objType = thisMsg.GetType();
  11:     objResults = objType.GetProperty("Message");
  12:     Processmessage(objResults.GetValue(thisMsg, null).ToString());
  13: }

Notice on line 4 I’m casting the results from the GetValue method to an IEnumerable.  From there I can run through the objects and use reflection to pull out the individual properties.  Not the cleanest approach, but it works well if you are in a situation where the type of your results are not known to the consumer.

Circular Reference Error in Silverlight

I’m working on some demo projects for some presentations I’m doing for the Spring SSWUG .NET Development Virtual Conference.  More on the conference later.  While working on the demo code I ran into an issue when trying to reference one of my base classes.  I kept getting an error related to a circular reference.  I checked all my references in both projects and could not find the issue.  Finally, David Yack gave me a pointer that fixed my problem.  It was a problem with the project dependencies.  To fix this you need to change the dependencies.  To change the dependencies right click on the solution and select “Project Dependencies”.

ProjectDependencies

Make sure that the project you are referencing does not have a reference to the current project.

LINQ : The DBA vs the Developer

At the Rocky Mountain Tech-Trifecta Eric and Johnson and I did a session related to this topic.  David Yack wanted us to do something that he could use to promote the session during his keynote.  So, we went over the top and created this video.  Enjoy!

Rocky Mountain Tech-Trifecta : A Week Later

It’s been a week since the Rocky Mountain Tech-Trifecta and I’m still getting caught up and processing everything that I learned there.  I presented a couple sessions and I also attended a bunch of sessions.  Fun stuff.  I think the event was huge success.  Thanks to my employer Colorado Technology Consultants, Inc. for letting me spend so much time volunteering for the event.  A special shout out to Julie Yack for all the time and effort she put in.  Please visit her blog at http://julieyack.blogs.com for a couple cool pictures from the event as well as some fun facts.

As stated above, I did two sessions at the Tri-Fecta.  The code and slides are below.  Please email me any questions or comments to benh@coloradotc.com.  You can also catch up with me on Twitter.  My handle is benhnet.

Thanks again to everyone that volunteered, organized and attended.

LINQ : DBA vs Developer

Design Patterns For UX

Updated 3/3/2009: I forgot one of the projects being referenced in the Design Patterns for UX.  I have updated the link so please download the project again and it should work.

Rocky Mountain Tech-Trifecta – Less than one week away

For those of you in the Rocky Mountain area we are one week away from the Tech-Trifecta in Denver.  In case you live in a cave, the Tech-Trifecta is a free event including three tracks:  .NET Development, SQL Server and Windows.  If you have not registered please do at www.rmtechtrifecta.com.  In case you didn’t know the speaker and topic schedule has also been updated.  We have some unbelievable stuff going on.  I can’t believe this is a free event!  Please join us.  I will be speaking there as well and I hope to see you.  If you can’t make one of my sessions, please stop me in the hall or atrium and say Hello.

Also, I am organizing a Skiing\Boarding day at Copper Mountain on next Sunday the day after the event.  Anyone is welcome but please register for that event as well so we know how many discounted tickets we will need.  The link to register for the Skiing\Boarding event is also on the Trifecta site.  I am looking forward to the Trifecta, but I’m also looking forward to blowing of some steam the day after.

Silverlight is the Future?

Just wanted to pass on this link to a post from Rocky Lhotka.  He describes why many of his new projects are starting to favor Silverlight over ASP.NET and Win Forms.  It’s a quick read and gets you thinking.  Check it out:

http://www.lhotka.net/weblog/WhySilverlightIsTheFuture.aspx

More Windows 7 Info

I came across this Windows 7 informational site yesterday on Gizmodo.  They have some great tips and tricks and also walk you through the installation process.  I’m sure there are more sites out there related to Windows 7.  Anyone have any others I should check out?

.NET Events in Colorado

I know January is almost over, but to me the year is still new.  I wanted to inform everyone about all the awesome User Groups and Community events in Colorado.

One of the most exciting upcoming events is the first ever Rocky Mountain Tech Tri-Fecta on Saturday, Feb. 21.  I cannot explain how cool this event is going to be!  It’s basically an all day geek fix.  There will be sessions related to .NET development, SQL Server and Windows Server.  So, if you work with MS products or know someone who does this is the event for you.  We have tons of speakers (Scott Hanselman is coming!) from all over the country and many who work for Microsoft and have inside info you cannot get anywhere else.  If you like what you are hearing please be sure visit the www.rmtechtrifecta.com site to register for the event to reserve your spot.

Next I wanted to let people know about the South Colorado .NET User Group.  I have taken over the leadership of this group from Julie Yack.  Julie Yack, David Yack and David Milner round out the leadership team for this group.  Next Tuesday we have Kathleen Dollard coming down from Ft. Collins to talk about rethinking Object Orientation.  SHould be great!  Please check out the link above to get more details.

Here are the links to all the MS related user groups I can think of in Colorado.

Denver Visual Studio User Group

North Colorado .NET User Group

Boulder .Net User Group

Colorado Springs SQL Server User Group

Denver SQL Server User Group

Colorado Springs Windows User Group

Rocky Mountain Windows Technology User Group

Please let me know if I missed a group.

Windows 7 Beta Stability is Solid!

I took the plunge last weekend and loaded the latest Windows 7 Beta on my laptop.  I decided to just go for it.  I had already loaded it on a spare laptop from work, but until you use something on a day to day basis you don’t really get a good feel for it.  Overall the experience has exceeded my expectations.  Here is a list of things I like:

  • The most impressive thing was the easy of installation and driver support.  I have an AMD Turion 64 X2 laptop.  The laptop was loaded with Vista 32 bit.  I decided to go all in and load the 64 bit version of the Beta.  Install was clean and the first time I logged in my screen resolution was really low.  However, after the first login Windows Update ran automatically.  Once that was done and I restarted the machine and was happy to find that my video and audio where back to normal.  I’ve been running for 5 – 6 days now smoothly and without a crash.
  • Another thing I have been happy with is the power management.  I have three kids under the age of 6.  So, I like to move around with my laptop while I keep one eye on them.  The power on my laptop seems to last longer without sacrificing connectivity or performance.
  • Next, The new task bar is really useful.  Instead of having multiple entries in the task bar for every window, Windows 7 groups them by application.  This is big.  For example when I’m using Outlook I frequently have multiple messages along with calendar entries, contacts etc open at once.  Windows 7 shows one icon on the task bar.
            • image
  • Then when I hover on that icon it expands and shows all the windows opened related to Outlook.
            • image
  • Very Cool!

A couple things I don’t like so far.

  • Support for multiple monitors is a bit difficult.  Maybe I just need some time to get used to it, but it took some extra clicks to get my second monitor configured.  I also had to save my settings multiple times to get it to work.  Not a big deal, but kind of annoying.
  • I also was disappointed that there is not support for mounting ISO files built into the OS.  Also MagicDisk, which is the one I used on Vista, did not work.  I found tons of blogs on this and finally loaded PowerISO.  PowerISO worked fine, but the fact that this took so long bothered me.

I will post any other things as I come across them, so far I’m running without a hitch.  The bottom line is that if you are thinking about trying it I would recommend it.  It is beta software so buyer beware, but so far this buyer is very satisfied.