Rants Tagged with “.NET”

<<  <  1  2  3  4  5  6  7  8  9  10  11  +  >  >>  (Total Pages: 17/Total Results: 165)

Astoria is now ASP.NET Data Services

Astoria has been renamed (ASP.NET Data Services) and added to the ASP.NET Extensions package (which includes the MVC support as well as other facilities).  Looks like ASP.NET Data Services is slated for a release in Q2 2008.  If you're interested in Astoria, go grab the CTP here:

http://asp.net/downloads/3.5-extensions/

New CTP's from Microsoft...

Over the past week there have been a flurry of new projects coming out of Microsoft, mostly in the form of CTP's.  I've been downloading like crazy and will likely be discussing my experience with them in the coming week.  In case you missed any of them:

I expect that with the release of the EF Beta 3 means Astoria is coming soon.  I'll let you know when it drops! Time to start digging in. 

Visual Studio 2008 for .NET 2.0 Development - An Interesting Quirk

I've been converting some projects to Visual Studio 2008 (but not .NET 3.5) to see if I like the new IDE better than 2005.  So far I can't tell a big difference (though the improved Script debugging is nice).  I did find out something interesting...

I use the 'prop' snippet (if you don't know what this is, in 2005 or 2008 type 'prop' {no quotes} and hit tab twice) to add simple properties.  In 2005 it stubs out the field and the property.  But in 2008 it stubs out an implicit property.

If you are not familiar, implicit properties look like this:

class Foo
{
  public int MyProperty { get; set; }
}

The compiler creates a field for you at compile time automatically.  Cool, right?  Well I was writing some new code and hit the 'prop' snippet in 2008 and got the new syntax but I was perplexed.  Doesn't 2008 know I am running against NET 2.0?  This certainly won't work, right?

Nope...it works.  Why? Because you are targeting the 2.0 Framework but using the C# 3.0 compiler.  Consider the following code:

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication8
{
  class Program
  {
    static void Main(string[] args)
    {
      Foo foo = new Foo() { MyProperty = 15 };
      Console.WriteLine(foo.ToString());

      string[] names = new string[] { "Shawn", "Bob", "Alice" };
      Console.WriteLine(names);

      // CAN"T USE LINQ as System.Core and 
      // System.Linq require .NET 3.5!
      
      //var coll = from n in names
      //           select n;
      //Console.WriteLine(coll);

      Console.ReadLine();
      
    }
  }

  class Foo
  {
    public int MyProperty { get; set; }

    public override string ToString()
    {
      return MyProperty.ToString();
    }
  }
}

The simple property defined in the Foo class works because the C# compiler is creating the correct code for the .NET 2.0 Framework to use.  Notice that I tried to do some LINQ code but that requires System.Core and System.Linq (both of which are only available in the .NET 3.5 Framework. As long as you are using C# 3.0 features that don't require .NET 3.0 or 3.5 assemblies, the compiler features still work.  If you were paying attention, I used the object initializer syntax too. 

The thing to think about is that if you are using VS 2008, you're using the new compilers (VB and C#) but targetting the right version of the Framework.  I don't know this for sure, but I suspect that targetting .NET 2.0 is actually targetting .NET 2.0 SP1.  I'll know soon when I try to deploy my first site to my 2.0 host.

This may be a boon for people stuck on the .NET 2.0 framework for deployment but want to use some (not all) of the new C# 3.0 features.  I haven't tried this in VB...i'll leave that to my VB MVP's!

Fun with .NET 3.5 - Part 1.1?

After digging into the TimeZoneInfo class, John Meyer pointed me a the new DateTimeOffset class and a MSDN article on choosing between DateTime, DateTimeOffset and TimeZoneInfo classes. I think I am more confused by the article than before.  Here are a couple of key bits of information:

  • DateTimeOffset is shoehorned into .NET 2.0 SP1, .NET 3.0 SP1 and .NET 3.5.  Not really a 3.5 requirement, but need to have patched Frameworks to use it.
  • DateTime and DateTimeOffset offer similiar but different functionality.  DateTime should be used for non-TimeZone specific use. DateTimeOffset can conatain the date/time information and the offset for that date.  Note that this is an offset, not what time zone it is in as they are different (but related) pieces of information
  • TimeZoneInfo, on the other hand, is all about specific time zones.

The article goes on to say two confusing statements:

Although the DateTimeOffset type includes most of the functionality of the DateTime type, it is not intended to replace the DateTime type in application development.

...and...

DateTimeOffset should be considered the default date and time type for application development.

I think I understand it, but it is very confusing.  In addition, its unclear how this relates to database data (I don't think there is a data type in SQL Server that encompasses offset and date/time information.)

Installing Visual Studio 2008 over Beta 2

Scott Guthrie has a new blog post instructing people how to cleanly uninstall all the Beta 2 bits on a machine before installing the RTM of Visual Studio.  This is a great list but if you're an early adopter like I am beware. 

If Beta 2 was your first test build of Visual Studio 2008 (Orcas), you should be good.  If you installed Beta 1 or any of the CTP's, I have found that paving a machine is the only way of really cleaning up some of the crud left by the earlier betas. Beta 2 was very good about cleaning up in an uninstall scenario, but Beta 1 was not (as well as not behaving great side-by-side with VS 2005).  It was a beta afterall so no harm no foul.  But if you have installed early bits, i'd suggest starting with a clean machine.

On the other hand, if all you have is VS 2005 on your machine, the RTM (like Beta 2) works great side-by-side for those of us who need to keep 2005 sln file compatiility.

Fun with .NET 3.5 - Part 1

I've been digging into the .NET 3.5 runtime to find any tidbits that didn't make the front pages of everyone's blogs this last year.  You can find the big stories anywhere else, I want to cover the small interesting stories of what's new in the Framework.  I'll be covering some classes over the next few days that I've found in the .NET 3.5 Framework (and hopefully I don't find anything I didn't notice in 2.0 or 3.0, but feel free to correct me if I am wrong).

Here's the first tidbit: TimeZoneInfo.  This class allows you to enumerate and convert from specific time zones.  We could do convertions to and from UTC and if we knew the offsets we could do these calculations before but now this new class allows us to actually look at the time zones.  It reads these time zones from the registry so it is not hard coded with the time zones and any system updates should be supported.  Here is how it could be used:

  class Program
  {
    static void Main(string[] args)
    {
      var zones = from zone in TimeZoneInfo.GetSystemTimeZones()
                  where zone.StandardName == "Pacific Standard Time"
                  select zone;
      if (zones.Count() == 1)
      {
        TimeZoneInfo zoneInfo = zones.First();
        DateTime now = DateTime.Now;
        Console.WriteLine("Current Time: {0}{1}In {2}: {3}", 
          now, 
          Environment.NewLine, 
          zoneInfo.StandardName, 
          TimeZoneInfo.ConvertTime(now, zoneInfo));
      }
      Console.Read();
    }
  }

 

Notice I am using a simple LINQ query to find the right timezone and then using it to convert local time to a specific timezone.  Enjoy!

Silverlight Data Example now using Astoria's Silverlight Client API

I've updated my Silverlight 1.1/Entity Framework/Astoria mashup to use the Astoria Silverlight Client API instead of raw JSON serialization.  The code contains both methods (but they are switched out with a project-level #define). If you're interested in seeing how this works in practice, go grab the code.  Here's a direct code link:

http://silverlightdata.com/mashup.zip

 

SilverlightData.com Source Now Available

For those who do not know what the SilverlightData.com site is about...its an example of Silverlight 1.1 working with Entity Framework and Astoria.  When I released SilverlightData.com last month, I had expected to allow users to download the source code so they can get a taste of what Silverlight 1.1 and Astoria together would look like.  Unfortunately because of a bug on my part, the source link did not work. I've addressed that and you can now download the source code. 

Here's a direct link to the source code:

 

.NET 3.5 Namespace Map - And a Curiousity

I was reading through the new .NET 3.5 printable map (i.e. poster) to see if there was anything in .NET 3.5 that i've missed out on looking at. The attempt here is to show you what is new, what is in the Compact Framework and just generally try and map concepts to namespaces.  Here are some observations:

Layered Framework...Really?

In a small graphic in the bottom right they attempt to explain that .NET 3.0 and 3.5 are additive to 2.0.  It indicates that 3.0 is WCF, WPF, WF and Cardspace (remember WinFX?).  What is interesting to me is that 3.5 is indicated to be LINQ, AJAX and REST.  Huh?  AJAX 1.0 was an addon to ASP.NET 2.0 so saying 3.5 is about AJAX is a little wierd.  If REST is part of it, where is it?  I hope they don't mean Astoria as it won't be released until *after* .NET 3.5.  I couldn't find it.  Anyone?

Changes to WinFX?

I scoured the WCF and WPF namespaces and couldn't find any changes at all. I was hoping for a point release of some changes or some additional functionality (Converters for WPF and AJAX compatibility for WCF). This doesn't mean there isn't new functionality, it just wasn't obvious from this list.  I am hoping to find a 3.0/3.5 changelog but I haven't found it yet.

 

If you're one of these people who like to have posters, get this PDF now and print it...but otherwise its worth a quick view.

 

UPDATE: Looks like I missed System.SerivceModel.Web and System.ServiceModel.Syndication.  These two namespaces do add some REST API support and probably fit into the Astoria/Silverlight story.  System.ServiceModel.PeerToPeer (et al.) are also interesting that might be fun to play with.  I will be prototyping some stuff this week with it.  Hopefully it will be something I can share with my readers soon.

Silverlight + Entity Framework + Astoria == Crazy?

I've been digging into the Entity Framework and Astoria and decided to create a quick little mashup of Silverlight and those two technologies.  The result is this little product viewer using the Northwind database:

The goal of the project was to use Silverlight 1.1 to design the UI, Entity Framework to design the DAL and use Astoria for the client-server communication.  I am pretty happy with the result.  I am using September previews of Entity Framework and Astoria as well as the Alpha of Silverlight 1.1 so the site may have problems from time to time as these are early releases of the products.

Astoria in particular is a very early build (and they've even changed the search syntax already so when the new version is released I'll change this). The September version of Astoria comes with a Silverlight client data layer that just does not work for me currently.  But that wasn't a problem as Astoria (for those who don't know) is a REST-based API for access a data model. Astoria supports returning results in XML, JSON and RDP.  So all I did was use the JSON format and Silverlight 1.1's built-in JavascriptSerialilzer to convert the results to in-memory objects.

You can download the source here:

http://www.silverlightdata.com/mashup.zip

UPDATE: Doesn't seem to work with Firefox.  I believe this is an issue with Astoria (astoria is changing the search syntax to be more compatible with other browsers).  Might also be my resizing logic.  I'll see if I can get it working with FF later this week.