<CharlieDigital/> Programming, Politics, and uhh…pineapples


WF Passivation Services Issues

Posted by Charles Chen

If you're expecting the WF (Windows Workflow) passivation services to work
out of the box, well, you're half right. 

From one of my workflows, I've been able to trap that an error was being
thrown at some point during execution, but it wasn't clear what the
actual error was or what was causing it.  I knew it had to do with passivation
services since everything was just fine and dandy once I removed the passivation
services from the equation.

From the runtime level, I received the following not-so-helpful error

Workflow with id "[some-guid]" not found in state persistence store.

Just on a whim, I attached SQL Server Profiler to the database instance where
the persistence store is attached to track the queries and lo-and-behold, the
mystery culprit surfaced:

declare @p10 int
declare @p11 uniqueidentifier
set @p11=NULL

in Assembly ''Zorch.Alta.EastCastle.Workflows, Version=,

Culture=neutral, PublicKeyToken=null'' is not marked as serializable. Type
Assembly ''Zorch.Alta.EastCastle.Workflows, Version=,
Culture=neutral, PublicKeyToken=null'' is not marked as

23:59:59:997'',@result=@p10 output,@currentOwnerID=@p11 output
select @p10,

Well, yeah, duh!  It seems so obvious after the fact.  So the moral of the
story is to make sure that all of your classes are marked with serializable 😛
I'm just not sure why they decided to place the error message in the procedure
call to insert the instance state.  Why not actually raise an error to the
workflow runtime that a class was not serializable?

Filed under: .Net, WF No Comments


Posted by Charles Chen

That's gotta hurt:

Windows Vista is Windows ME
Part 2. It took five years to develop because three of those were spent
building a brand new code base that didn't work at all and wound up
getting scrapped, and the remaining two were spent just tweaking the XP
code base. Almost all the features we were promised early on were
discarded and what we end up with is a warmed over Windows XP that
doesn't even do us the dignity of working properly out of the box. I
think it's particularly telling that they've already announced the next
major Windows release for late 2009.

From NotebookReview.com.

Filed under: Technology No Comments

Another Reason to Switch to Sprint?

Posted by Charles Chen

Yet another reason?  You can give the "one-fingered salute to Verizon totally painless to you ".

The timing couldn't have been more perfect...


Thoughts on Sprint PCS

Posted by Charles Chen

This post is completely off topic, but I feel like I have to get it out there for people who are just sick of looking at $$$$ cell phone bills.  If you think about it, a family of four will probably spend upwards of $2500/year on cell phone service! 

So I've been on Sprint now for about 2 months.  At first it was a bit scary jumping ship after having been on Cingular for several years and of course no one in our area had Sprint (that we knew) so we had no idea how well Sprint would work out for us.  But I knew I had to switch since we were paying $180 for myself, my mother, and my sister (Cingular) plus another $140 for my wife, her dad, and her sister (Verizon) at a total of $320+ which was just insane.

I ended up eating the cancellation fees of $175 with Verizon to bring my wife over to Sprint since I figure that I would make that up over less than a single year just by switching to Sprint (I would only have to save $15/mo over 12 months by switching, but I'm saving more like $40/mo).  With 4 lines now on Sprint, TWO of which have unlimited data, insurance, and 300 text messages, the total cost is $180 after all taxes and surcharges.

So here's my two month conclusion: Sprint is the real deal (okay, maybe it's a bit early to proclaim that until I get my rebates back for my phones).

  • When I've called, I've always been able to reach a live customer service representative within 3 minutes (just have to navigate through the menus, maybe 4 deep). 
  • Customer service has been top notch in my opinion (I mean, no worse than expected).  I was promised a credit for my activation fees by the salesperson in the store, but it wasn't reflected on my first bill.  However, a single call to customer service cleared that up right away. 
  • The online tools are also well done, useful, and complete. 
  • Phone service is okay - no better or worse than Cingular in my house (there is a weird dead spot around my house).  I have noticed that where we do get a full strength signal (which is pretty much anywhere but my house), the voice clarity is exceptional.
  • Did I mention unlimited data (fast, too) for only $15.00 a month?

The thing that seals the deal for any family thinking about this plan (up to 5 phones) is that extra lines cost pretty damn close to the advertised $9.99.  For someone like my mother, who doesn't use text or data services, after surcharges, she comes in just a shade over $14.00, which is awesome.

On the other hand, I'm still getting raped by Verizon on my sister in law's and my father in law's Verizon bill: $110 this month!  No overages!  And my father in law didn't even make one call from his cell phone!  What?!?


Setting Links in Word Programmatically

Posted by Charles Chen

Since I didn't find anything on this topic via Google...

Just a quick "how to" on setting links in Microsoft Word programmatically (in this case, C#):

public void CheckRuntime() {
object reference = null;

try {
reference = Marshal.GetActiveObject("Word.Application");
catch (COMException) {
System.Console.Out.WriteLine("No instances found...");

if (reference != null) {
try {
System.Console.Out.WriteLine("Found running instance!");

ApplicationClass wordRuntime = (ApplicationClass)reference;

System.Text.StringBuilder buffer = new StringBuilder();
foreach (Document document in wordRuntime.Documents) {
buffer.AppendFormat("{0}|", document.Name);

if (wordRuntime.Selection != null) {
System.Console.Out.WriteLine("Selected text: \"{0}\"",

object optional = Missing.Value;
object url = "http://www.google.com/";

if(wordRuntime.Selection.Hyperlinks.Count == 0) {
ref url,
ref optional

string.Format("Currently open documents are: {0}",
finally {

The code is wrapped in a function call I'm using for testing. The key part of this is detecting the currently selected text and using the ApplicationClass.Selection and then invoking _Add. The method takes three parameters. Make sure that your first parameter is a Range class instance, your second parameter is passed by reference, and your third parameter (the SubAddress) is set to System.Reflection.Missing.Value.

This should set the text point to any input URL.

Filed under: .Net No Comments

Revisiting Spring.Net

Posted by Charles Chen

Spring.Net is an application framework which has its roots in the Spring Framework for Java.

Now first of all, I know many developers have an averse reaction to the use of the phrase "application framework" and immediately reject such things without second consideration.  I always hear tales that begin like so: "Well, on this one project, we used an application framework and it ended up not doing anything exactly the way we wanted and we had to modify it anyways..."

Four thoughts on this:

  1. No two applications are exactly alike.  If that were so, we'd all be out of jobs as software engineers because it'd probably have already been done before.  As well, no two application frameworks are alike (although on some level, Spring is interchangeable with Castle).
  2. Spring, I have found, does not restrict me in anyway in terms of my solution design.  If anything, it frees me to use more flexible designs and allows me to create much cleaner and better designs.  Inversion of Control is your friend.
  3. Spring includes the source.  Dude, if it doesn't do exactly what you want it to, you are 100% free to modify and reuse it (and maybe even resubmit it to the project if it's well written and useful).
  4. The documentation and development team on Spring (and Castle to a lesser degree) are great.  The documentation is very thorough and well organized and the developers are constantly monitoring the discussion forums and reaching out to users.  Many times, with any sort of large library, you may be under the impression that it doesn't do something (thus leading you to believe that you have to write it anyways and believing that it was pointless to use the framework), but it may actually be the case that you simply haven't found the facilities in the library to accomplish your task.

On top of this, the support forums and developers working on the framework are great resources for hashing out design ideas (outside of one's normal circle of peers).

Yes, it's true, Spring requires the use of what can become massive XML configuration file(s).  Yes, it can be difficult for first timers to grasp inversion of control, understand what exactly it is that Spring offers, and in general, find anything in Spring that would significantly make one's life easier as a developer without a learning curve.  Yes, Spring is huge; it encapsulates a lot of "stuff" that can be confusing and seem like bloat one's first time encountering it (I myself only ever use a small subset of the features of Spring).

However, in the end, I think Spring brings so much to the table (too much for me to list here), it's hard to discount it without at least giving it a real evaluation.  For any sort of non-trivial application, Spring allows the designer to add much more flexibility and decrease the complexity of the codebase by encapsulating a lot of the dirty work.  (I would agree that there is a complexity cutoff where if your application sits below this cutoff, it's simply not worth it to include Spring in the discussion, as the time it takes to understand and find its usages in your scenario would not be worth it).

I've been using Spring for almost a year now and I simply can't imagine writing an application without it.  With the latest release, the introduction of the data access library, Spring becomes even more compelling by removing a lot of the boilerplate code that one would write when performing data access.  Admittedly, in a sense, it is a replacement of one set of boilderplate code for another, but it is a much more elegant design than using raw ADO or even Enterprise Library for that matter.  Spring introduces the usage of a delegate/callback pattern for "rendering" the returned data rows and sets into domain objects and sets.

I use the term rendering because this is the same exact pattern that I've been using with regards to the JavaScript that I've been writing for my AJAX enabled applications.  It's an elegant pattern that, in JavaScript, allows for decoupling of the code to retrieve that data from a web service and the code that renders the data.  In a sense, Spring does the same, except, instead of rendering a UI, it renders a domain object (or set) using the delegate, which decouples the data access plumbing from the building of the domain object.

Having used NHibernate previously, I have to say that in many cases, I still prefer performing my own data access code and domain object rendering as it allows me much more flexibility and control.  There is less processing overhead and not to mention (when I last checked) NHibernate still does not natively support generic types.

I've mostly been sticking with Enterprise Library, which is basically just a step above raw ADO, but I'm gonna give this a shot since it's yet another step or two above Enterprise Library.

On another note, it seems like Microsoft's Patterns and Practices Group is finally releasing the next version of Enterprise Library.  In a sense, EL is a "necessary evil".  As far as 2.0 goes, I cannot say that it does anything particularly better than other libraries that fill the same purpose as any given block, but what it does do is it encapsulates multiple functional spaces (logging, data access, exception handling, configuration) into one.  In addition, having the Microsoft Seal of Approval also helps with acceptance.  As an example, the rolling flat file trace listener has had a counter part in log4net since I've been using it (over 1.5 years now).  The data access application block, while it does clean up data access code, is still pretty close to raw ADO.Net usage patterns; in other words, it brings almost nothing to the table (almost; I still endorse it over raw ADO.Net to be sure).

It'll be interesting to see what this Object Policy Application Block actually does.  It seems like it's conceptually similar to Spring's IApplicationContext or Castle's Windsor Container.  I'm not one to latch onto a product simply because it's from Microsoft's P&PG, so I'm hoping they can actually bring something new to the table to make their library more compelling than Spring or Castle (both of which are much more mature by now and encapsulate a far greater set of features).

As for the any concern over the longevity of Spring and Castle, I feel pretty confident that what happened to NDoc, will not be happening to Spring or Castle.

Filed under: .Net, Dev, DevTools 5 Comments

The Allure of the WWW

Posted by Charles Chen

Not everyone can appreciate the simple elegance of the ethereal structure that we know as the Internet.  It is not the average person that will sit and contemplate the transmission of data from one node to another, thousands of miles away in mere milliseconds, and be impressed and appreciative of the amazing times we live in (I mean, just 20 years ago, you had to actually walk into a store to buy porn 🙂 (*aherm*...not that I know anything about that)).

Most people are just happy that they can log on in the morning and get their mail in Outlook or check the weather on their local news sites, never taking a moment to bask in the glory of the immense amount of data that flows through copper, fiberglass, and the very air that we breath (isn't it weird to think that right at this moment, several megabits of data are probably bouncing off of me (or worse, passing through me (and you!))), each picosecond.

But then again, not everyone is a software engineer. 

Via Gizmodo.


Most Annoying Error Ever.

Posted by Charles Chen


So I've been working on this Windows Forms app for the past month and recently, it started developing this very odd error that occurs only after a successful build, just as I fire up the window.  Behold:

Super annoying error that makes no sense...

Argh!  What's worse is that it pops up not once, not twice, but three times each time I show the form with that super annoying Windows XP "Critical Stop" sound clip each time.  BUT it only happens if I launch the form from VS! These things...they infuriate me because it's virtually impossible to track down.  Throw me a bone, Microsoft, at least tell me what line it's on (which brings me to another point: NullReferenceException - at least when deployed in debug mode, can't you guys just tell me what reference was null?).

I mean, it would be easy if it said something like "Unable to cast object of type 'X' to type 'Y'" - that would make perfect sense, duh! - but this is just baffling.  It's not like I'm getting complier errors either.  I dunno...I just can't figure out why it would only throw up this modal dialog only when I launch the app (without debugging) from VS.

:: grumble :: grumble ::


Filed under: .Net, Rants No Comments

My Thoughts on WF

Posted by Charles Chen

As I commented in a post on Paul Andrew's blog regarding what WF is and what it is not:

As I've been working with WF these last few weeks, I've come to form another view of WF and what it means for developers: in a way, it *forces* developers away from some bad design practices since a WF itself has no GUI and no visual user interface.
To expand on that, it forces developers who would otherwise readily hash their ASP.Net and WinForms GUI code in with the business logic to think in  a manner that separates the core business logic from the visual interface code.
The number of developers that still write monolithic projects that contain the UI and business logic is still all too high.  In studying from simplified working examples in text books, in MSDN documentation, and various articles one finds online, many developers do not gain a good understanding of how to separate the concerns of their code.
The downsides of this approach are immediately apparent after a little exposure to alternative design methods, yet for many developers, they simply don't see the light and continue to write their data access code right into the Click event of a Button.
I see WF as a way of moving developers away from this model by encouraging developers to encapsulate code in a WF program (a unit of business logic) or an activity

I would like to add to that, that in the end, WF is still "just code" (maybe my perspective is skewed after having written my own workflow engine). Don't be fooled by the drag and drop UI, the fancy terms (for example, tracking is nothing more than glorified logging that any learned developer could have easily implemented with log4net, a database appender, and a well defined logging policy), and the hype train in general.  When it comes down to it, for any significantly complex application or architecture, it still requires writing of much of the same code that you had to write before (and in some cases, you may end up writing more code to build a functionally equivalent solution) not to mention that whenever you adopt such a framework, you must learn the little nuiances and how the product architects intended for you to complete a certain task within the guidelines of the framework.

Just to share my take on it 🙂

Certainly, it is no "silver bullet", as Brooks would say, but it's definitely a step in the right direction. I am quite curious as to the actual adoption rate that we will see with WF in the coming months as it offers no immediate benefit (until perhaps we see a market for custom activities much like we have today for custom controls for the UI).  To most, it simply won't offer anything compelling and to top it off, it will require additional training to implement a solution using WF.

For me, personally, it's been fun picking it apart and seeing how the minds at Microsoft implemented the same functionality I implemented in my own workflow engine that I wrote for our project at Zorch (while certainly less polished, I like to think I was heading in the same direction...and in some cases, I wish WF offered the same features as I had implemented myself (that was my ego speaking ;-))).

Filed under: .Net, Dev, WF No Comments