Rockford Lhotka

 Tuesday, June 7, 2011

The final draft of the Using CSLA 4: ASP.NET MVC ebook is now online, and available for purchase.

If you own the Using CSLA 4 ebook series, you already own this new ebook and can download it from http://download.lhotka.net/Default.aspx?t=UsingCsla4.

If you are buying the ebooks individually, the new book is now available for purchase from http://store.lhotka.net.

This ebook also includes a code download, containing the latest ProjectTracker codebase. This includes the Mvc3UI project: an ASP.NET MVC 3 application built using the CSLA .NET business layer.

Books | CSLA .NET | Web
Tuesday, June 7, 2011 3:50:00 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Wednesday, May 4, 2011

I am pleased to announce that the Using CSLA 4: Data Portal Configuration ebook is available for purchase in draft form.

Owners of the Using CSLA 4 ebook series can also download the updated ebook draft.

This ebook (141 pages in PDF format) covers the use of the CSLA 4 data portal technology, which enables flexible n-tier deployments of your applications in 1-, 2-, 3- and 4-tier physical configurations. The ebook covers the use of the data portal in .NET smart client, Silverlight, WP7, and ASP.NET web applications.

The ebook also covers the authentication techniques supported by CSLA .NET, including Windows integrated domain or Active Directory authentication, the use of the ASP.NET MembershipProvider model and custom authentication against your own security data store.

The ebook includes a complete set of sample applications demonstrating the concepts and techniques discussed in the book.

Here is a high level list of the content in this ebook:

  1. Data Portal Deployment
    1. Data portal concepts
    2. Deployment options
    3. Using the local channel
    4. Using the WCF channel
    5. 4-tier Silverlight and WP7 deployment
  2. Data portal configuration reference
  3. Serialization
    1. .NET serialization
    2. MobileFormatter
  4. Custom data portal proxies
    1. Supporting multiple application servers
    2. Dynamically switching between online and offline mode
  5. Authentication models
    1. Custom authentication
    2. ASP.NET membership authentication
    3. Windows authentication
Wednesday, May 4, 2011 9:18:41 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Thursday, April 28, 2011

Today I spent hours trying to make one line of code work. Fortunately Miguel Castro was ultimately able to help me troubleshoot the issue thanks to his deep understanding of all things ASP.NET.

The line of code seems so simple:

var data = Roles.GetRolesForUser(“rocky”);

In this case Roles is the RoleProvider API from System.Web.Security, and the method returns a string array with the roles for the user.

This line of code works great in my aspx page. No problem at all.

But in the same web project it throws a NullReferenceException when called from a WCF service (in a svc).

No stack trace. No detail. No nothing. I Binged, and Googled, and created a whole new solution (figuring my first solution was somehow corrupted). But nothing helped.

To cut to the answer, this works in a WCF service:

var data = Roles.Provider.GetRolesForUser(“rocky”);

See the difference? Instead of relying on the static helper method on the Roles type, this code explicitly calls the method on the default provider instance.

(fwiw, I think this behavior is relatively new, because that code used to work. I just don’t remember how long ago it was that it worked – .NET 3 or 3.5 – so perhaps something broke in .NET 4?)

In any case, problem solved – thanks Miguel!!

WCF | Web
Thursday, April 28, 2011 5:46:57 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Monday, April 25, 2011

Dunn training will be holding their next CSLA training class in Atlanta, June 21-23.

If you are gearing up to use CSLA .NET and want some solid classroom training to get started, this is the way to go!

Monday, April 25, 2011 8:01:38 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Friday, April 1, 2011

The Minnesota chapter of IASA is holding an IT architect training event in May. Details:

Course Summary:

Foundation Core Skills - The Key Distinguishing Factor for IT Architects

  • Business Technology Strategy - Identified by Iasa members and global thought leaders as the core value proposition of any architect and the key set of skills in our profession, business technology strategy ensures immediate business value from technology strategy. It ensures that your organization will succeed in converting technology and IT from a liability to an asset.

Foundation Supporting Skills

  • Design- Architects commonly use design skills to create solutions to problems identified in developing technology strategy solutions.
  • Quality Attributes - Quality Attributes represent cross-cutting concerns in technology solutions such as Performance, security, manageability, etc that must be considered across the entire enterprise technology strategy space.
  • IT Environment - Technology strategy must include a general knowledge of the IT space including application development, operations, infrastructure, data/information management, quality assurance, and project management. The IT Environment skills prepare an architect for the IT side of a technology strategists job function.
  • Human Dynamics - Much of an architects daily role is working with other stakeholders to understand and define the technology strategy of the organization. The human dynamics skills represent the means for working with others in the organization including situational awareness, politics, communication and leadership.
Friday, April 1, 2011 8:12:16 AM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Sunday, March 27, 2011

I have been working on the Using CSLA 4: Data Portal Configuration ebook, part of the Using CSLA 4 ebook series. One section of the book covers the use of Windows Azure as the application server, where the server-side components of the CSLA .NET data portal and your application will run.

Perhaps the most interesting part of that section of the ebook is that there’s no meaningful difference between hosting in Windows Azure and hosting in IIS on an on-premise Windows Server. In fact, the only difference at all is that the project in Visual Studio is an Azure ASP.NET Web Role project instead of an Empty ASP.NET web project.

This is because Windows Azure allows WCF services to host in a web role in the same way IIS hosts WCF services. When using the WCF data portal channel, the server components are accessed through a standard WCF endpoint – nothing special or fancy. That means any place you can host WCF, you can host the data portal.

In my example solution, there’s also a Silverlight client app. It is part of that same Web Role app, so a user simply navigates to the web page in Azure that hosts the Silverlight app. The Silverlight app runs on the client, and uses the data portal to interact with the server-side components of the application running in Azure.

There is some potential value to hosting the data portal (your application server) in Windows Azure.

There’s the obvious scalability benefit. Because the data portal is stateless, and typical server-side business code in a CSLA application is also stateless, there is no problem with just adding more web role instances to the app. If more capacity is required on the server, just change the Azure configuration and just like that you have more capacity.

The business code running in Azure typically implements persistence. Another value of running the application server in Azure is that the application can store its data in SQL Azure. Pretty comparable to SQL Server, but based in the cloud. In that way, the entire app can be cloud-based, with the Silverlight client using client-side CPU and memory resources, while the rest of the app scales happily in Azure.

Alternately, the application could store its data in Azure Storage. That isn’t a relational data store, but does offer some interesting super-scaling capabilities that may be quite valuable.

In the end, perhaps the most notable thing to consider is this: when building an application using CSLA and the data portal, it is entirely possible to switch between hosting in IIS to hosting in Azure, and back again, without changing anything except the application configuration.

Sure, if you use Azure-specific features in your business code (like Azure Storage), you can’t easily move off Azure. But if you stick with SQL Server or SQL Azure, and avoid Azure Storage, the .NET Service Bus, and other Azure-specific constructs, CSLA can help you build an app that can exploit Azure, without being locked into Azure forever.

Sunday, March 27, 2011 6:11:17 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Saturday, March 26, 2011

There is now an alpha release of CSLA 4 version 4.2 available for download:

The big initiative for version 4.2 is to add support for the following platforms:

  • Linux and OS X (via Mono)
  • Android (via MonoDroid)
  • iPhone and iPad (via MonoTouch)

This alpha release does not include binaries for these platforms, but does include code and sln files (for Visual Studio and/or MonoDevelop) you can use to build the source on each of the platforms.

At this point in time we have the following:

  1. CSLA 4 builds and runs on mono in Windows and Linux.
    1. Core CSLA 4 functionality (Csla.dll) should be the same as on .NET 4.
    2. ASP.NET code using CSLA objects should work using Csla.Web.dll
    3. The Windows Forms support with Csla.Windows.dll is limited due to incompatibilities in data binding between real Windows Forms and the mono implementation of Windows Forms.
  2. CSLA 4 builds and runs on Android. Use the MonoDroid tools in Visual Studio to build Csla.dll.
    1. You should find behaviors and features for Android identical to that provided for WP7.
    2. There is not currently an equivalent to Csla.Xaml.dll for Android.
    3. No testing has been done around the use of any remote data portal channel – only the local data portal has had any testing.
  3. CSLA 4 builds and runs on iOS (iPhone/iPad). Use MonoDevelop on OS X to build Csla.dll.
    1. You should find behaviors and features for iOS identical to that provided for WP7.
    2. There is not currently an equivalent to Csla.Xaml.dll for iOS.
    3. No testing has been done around the use of any remote data portal channel – only the local data portal has had any testing.

Please remember, this is an alpha release, in the early stages of testing and stabilization. Any help you can provide in terms of testing and resolving issues is appreciated! Direct inquiries to http://forums.lhotka.net.

Other changes of note to existing .NET, SL, or WP7 users include:

  • When an async rule completes, rules for affected properties are now also run
  • BackgroundWorker from Csla.Threading is now available in WP7
  • Some cleanup work was done around CslaIdentity – this shouldn’t be a breaking change, but the internals are now quite different
  • Fix a bug in non-generic GetProperty where field wasn’t always set to the correct default value
Saturday, March 26, 2011 5:13:06 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Tuesday, March 22, 2011

Yesterday I set out to do “something simple” – to use Windows Server AppFabric to do basic health monitoring of a WCF service.

A few hours later, I was pulling my hair out and my brain was spinning.

The basic issue is that configuring and using AppFabric involves numerous moving parts, and that leads to a ton of complexity for something that is otherwise pretty simple. But there are a lot of moving parts:

  1. My app
  2. IIS
  3. ASP.NET
  4. WCF
  5. AppFabric configuration tool
  6. AppFabric Dashboard
  7. AppFabric event collection service
  8. SQL Server
  9. SQL Server Agent
  10. Machine.config
  11. Web.config
  12. Visual Studio
  13. NTFS security

To make matters worse, on my dev workstation I had SQL Express 2005, SQL Express 2008 R2, and SQL Server 2008.

What you are supposed to do is simply this:

  1. install your web site into IIS (create an IIS Application where the virtual root points to your web site directory)
  2. in IIS Manager go to the virtual root, and click the Configure link on the far right under the Manage WCF and WF Services label
  3. in the resulting dialog, click Monitoring on the left, then enable application monitoring
  4. call your service
  5. back in IIS Manager, double-click the AppFabric Dashboard option for your virtual root to see the dashboard, with the cute little counters showing that your services have been used

Of course that didn’t work.

In the end, I think it didn’t work because the AppFabric Event Collection Service (a Windows service that runs to collect event information) didn’t have NTFS security rights to read my application’s web.config file.

But that’s not the first thing I thought to check. No, the first thing I thought to check was whether data was getting into the AppFabric tables in SQL Server. It was not. So then (after a little googling with Bing), it sounded like the problem was that SQL Agent wasn’t running.

Of course it turns out that SQL Agent can’t run against SQL Express. But having three different versions of SQL Server installed was making this all very hard to troubleshoot. So I spent some quality time uninstalling SQL 2005 and 2008, and then installing SQL Server Developer 2008 R2 – so now I have a real up-to-date SQL Server instance where SQL Agent does work.

(again, I suspect that was all wasted time – but on the upside, I have a far less confusing SQL Server installation Smile )

All that work, and it didn’t help. Then it occurred to me that my configurations were probably out of sync. So I reconfigured AppFabric, and my app, and the web sites and virtual roots in IIS Manager – all to use the new 2008 R2 database. And things were out of sync, so this was necessary and good.

But that didn’t help either. Still no data was in the AppFabric database.

Finally, I found a page lurking deep in MSDN that contained good troubleshooting information. And in here were instructions on how to view the event log for the AppFabric event collection service – which couldn’t read my web.config file.

I thought I’d hit the jackpot, so I updated the NTFS permissions on my web folder so the collection service could read the directory.

Still nothing. So I went to bed, frustrated at the continual failure.

This morning I thought I’d try again. Still no joy. So I rebooted my machine, and then it worked.

So I suspect that the core issue was the NTFS file permissions for the collection service. But with all the other changes I made, some service didn’t re-read its configuration until the system was rebooted.

In the end, it only took me about 6 hours of work to get Windows Server AppFabric to monitor the health of my WCF service. Hopefully I’ll never have to go through that again…

Tuesday, March 22, 2011 9:13:40 AM (Central Standard Time, UTC-06:00)  #    Disclaimer