• Latest Posts

  • Latest Comments

  • Archives

Single Logic Tier, Multiple Presentation Tiers – In a 64-bit world

Wouldn’t it be nice if we had a single data and logic tier upon which any number of presentation tiers could display? For example, one logic tier but present via WPF (Windows Presentation Foundation) (both 32 and 64 bit), ASP.NET, MVC (Model-View-Controller), Silverlight, and Windows 7 phone? And, can I use the MVVM (Model-View-ViewModel) pattern to do this? For the data tier, I’ll use the ADO.NET Entity Framework’s Self Tracking Entities.

Is it possible? I hope to find out in a series of posts. For these posts I’ll focus on WPF, MVC, and Silverlight. While most of my work was in traditional ASP.NET Web Forms, recent work has been in MVC. I would like to do some site work in Silverlight. While it is clear I want be doing much web work in WPF, I’d like to see if entities can be designed to support these different tiers. In particular, I’d like to see MVVM support both WPF and Silverlight.

Current Challenge

I’ve spent a couple of days on this task already. Most of that is really just coming up to speed with Silverlight. It has been changing too fast for me to learn on the side. But now I feel that Silverlight 4 will meet most my needs and that maybe the pace will slow a little. Or at the very least, the knowledge gained on Silverlight 4 will not be obsolete so quickly.

During these two days it seems like there is a significant hurdle.

64-bit?

There are certain features I use in my entities which I have in a base library. Silverlight applications can only reference Silverlight Class Libraries. So in order for my base library (or any library below my presentation tier) to be used in Silverlight as well as other technologies it seems I have two choices: 1) Have two libraries – one Silverlight and the other .NET, or 2) use Assembly Portability nicely explained here in the CLR Team Blog.

So I went down the Assembly Portability path. Was doing pretty good until I checked in my code. (I use Team Foundation Server (TFS) even though it’s just my code to learn and experiment with the technology.)

My build didn’t work! “It worked on my box” cried the incredulous developer. (Of course it did, or you would not have checked it in.) I got the following error message:

C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets (104): The Silverlight 4 SDK is not installed.

I tried a couple of things, but then this post pointed out that since my build environment is 64-bit it would not work. Silverlight only supports 32-bit. OK… I suspect there is a design decision there to not use the Any CPU approach for Silverlight to keep the downloads smaller. They are always looking to keep that download small and fast.

I followed the advice in the post and managed to get my build to work. But what are the repercussions of this? And why did it build on my box? My box is 64-bit and I build everything as Any CPU. Does this mean that I can never use the Portable Assemblies in a 64-bit WPF application?

So I have a Canary that goes Tweet that I use for simple tests. I created a WPF application and if I press F5 to debug, I see this after I press the Tweet button once:

image

However, if I press Ctrl+F5 it seems that nothing happens. However, if I look in the event log I see the following entry (summarized):

Faulting application name: WpfTestApplication.exe<…> Faulting module name: KERNELBASE.dll<…> Faulting module path: C:\Windows\system32\KERNELBASE.dll <…>.

So after many different permutations, I’ve come to the conclusion that if you don’t want to box yourself out of the 64-bit Windows world, the Portable Assembly approach is not viable.

My Decision

I’ve been pacing back and forth for a bit… what should I do? What’s the big deal? Just back off to 32-bit and move on – right? But there’s this little voice inside saying, no, screaming, “Don’t Do It!”

And now I remember… I was working on implementing a WCF service to integrate TFS 2008 with another system.  The Team Foundation SDK was only 32-bit. However, the only server I had access to was a 64-bit machine. It turned out that if you have a WCF service hosted in IIS on a 64-bit box, your WCF service must be 64-bit. But wait!?! My TFS libraries were only 32-bit. HACK… I had no choice – WCF launched a console app that did the work.

The Portable Assembly approach is not for me. At least not at the very foundation of my code base.

Every machine I own runs 64-bit. Microsoft is strongly recommending 64-bit for their servers. I’ve seen some posts that indicated Microsoft was considering having Windows 7 only support 64-bit.

I think this setback will make having a common model tier a challenge.

1 Comment  »

RSS feed for comments on this post, TrackBack URI

Leave a Comment