Welcome to Microsoft .NET Framework 3.0 Community (NetFx3)

The .NET Framework is Microsoft's managed code programming model for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes.

Learn More...

WF Community Bloggers

Browse by Tags

All Tags » Workflow   (RSS)

  • Using an IronPython runtime service from Windows Workflow Foundation

    In this post I demonstrated how to create IronPython objects and call them from strongly typed .NET code. So suppose we want to do so with Windows Workflow Foundation where could we use this? Well the most obvious place would be a runtime service . The example below uses a very simple message that needs to be displayed but it is easy to see how to same concept could be applied in other places. But first the basics. I have created a very simple custom DisplayMessageActivity like this: public partial class DisplayMessageActivity : System.Workflow.ComponentModel. Activity { public DisplayMessageActivity() { } public string Message { get ; set ; } protected override ActivityExecutionStatus Execute( ActivityExecutionContext executionContext) { IDisplayMessageService service = executionContext.GetService< IDisplayMessageService >(); service.Display(Message); return base .Execute(executionContext); } } Next I have created a very simple workflow with only the DisplayMessageActivity and set the Message property to: "This is the message to show.". You might have noticed in the code above that I am looking for a service of type IDisplayMessageService . This is pretty simple as well and looks like this: public interface IDisplayMessageService { void Display( string message); } In this case I am using an interface but you could just as well use a concrete baseclass with virtual methods. For the actual implementation I created two classes in IronPython, the first displays the Read More...
  • Red Gate to continue development of .NET Reflector

    .NET Reflector, by Lutz Roeder, must be one of the most useful tools I have when developing .NET code. Usually it is the first thing I install right after Visual Studio not even waiting until I need it because I know I will. So the big news is that Red Gate, makers of the Ants profiler and lots of other tools, are taking over from Lutz Roeder and will continue developing .NET Reflector. Interesting move and I hope this means a bright future for the .NET Reflector. Read more about this here . Enjoy! www.TheProblemSolver.nl Wiki.WindowsWorkflowFoundation.eu Read More...
  • Book review: Pro WF by Bruce Bukovics

    Windows Workflow Foundation, WF for short, is one of the technologies I work a lot with and as a consequence I own several books about WF. Comparing this book with the others I can only say it is one of the best books you can get on the subject. It has a good coverage of almost all the subject you are going to need to know. Not only is there a good coverage but the explanation and examples are very clear. Now there are a few thing missing from the book. As it was written with the .NET framework 3.0 there is no coverage of the WCF integration that comes in the form of the SendActivity and the ReceiveActivity. While this is unfortunate it is also understandable and I can only hope that the author has the time to update the book with one more chapter. For a book this size, about 700 pages, I was amazed at how little I could find that I didn't like. In fact one of few errors I could find is the statement that only a single instance of the WorkflowRuntime can be created per AppDomain. This is a myth that stems back to the first beta's where it was briefly the case but the restriction has been lifted long ago and has never been part of the released product. But given the size of the book and how few people ever need to create multiple WorkflowRuntime objects it is hardly a big objection. So my advise: If you are getting into Windows Workflow Foundation make sure you buy this book! Enjoy. Read More...
  • Visual Studio 2008 Service Pack 1 available

    It is available from the subscriptions download at http://msdn.microsoft.com/en-us/subscriptions/default.aspx Get it while it is hot Enjoy! Read More...
  • More on using a TransactionScopeActivity within a ReceiveActivity

    In a previous blog post I write about what happens when you place a TransactionScopeActivity within a ReceiveActivity and an exception occurs that is supposed to roll back the transaction. In short the story was very bad and we could come up with only a partial workaround, not a pretty sight. But there is more to it than just that little horror story. Suppose you do the obvious and place the a TransactionScopeActivity within a ReceiveActivity and no exception occurs. Say like the workflow below, please note that the codeActivity1 only sets the return value and causes no error. Now the transaction is committed and the WCF call returns perfectly normally so everything is good right. Well not quite The obvious first point is that the TransactionScopeActivity serves no real purpose. After all if it isn't allowed to fail under any circumstances why bother with it in the first place. Well ok there is the point of doing several updates as a single transaction so other users cannot see a partially committed order but that is about it. But that is actually the least of my worries as there is a far bigger issue to worry about and that is called workflow persistence. Yes that is right. After all when we are using a TransactionScopeActivity workflow persistence is mandatory. The TransactionScopeActivity is decorated with the PersistOnClose attribute so the state of the workflow will be persisted as soon as the transaction is complete. And normally that is a good thing but in this case Read More...
  • SQL Server Compact 3.5 SP1 released

    Steve Lasker just announced that SQL Server Compact 3.5 service pack 1 is released, read his announcement here . They added support for the entity framework, great stuff. And another neat feature is native 64 bits support. No longer do you need to target X86 and use WoW [:0]. Great if you are using my SQL Server Compact Workflow Persistence Service . Enjoy! Read More...
  • Using a TransactionScopeActivity with a WCF ReceiveActivity

    I got an email from a friend last week asking about using a ReceiveActivity and, while receiving, using a TransactionScopeActivity to transitionally save some data in a database. Seems like a common enough scenario right? Well he was having some problems. If everything worked and the transaction succeeded everything was fine and the answer came back. But if an exception occurred and the transaction was aborted be was receiving a real weird error: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Workflow service unexpectedly unloaded from memory while executing a ReceiveActivity. Make sure that the the workflow does not contain any blocking activities within a ReceiveActivity. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.InvalidOperationException: Workflow service unexpectedly unloaded from memory while executing a ReceiveActivity. Make sure that the the workflow does not contain any blocking activities within a ReceiveActivity.). If we where to believe the message there was a blocking call, something there most certainly was not! And to make things more confusing, if we removed the TransactionScopeActivity and just let the exception occur it would bubble back to the client just as it was supposed to. So what gives? Well a lot of people looked at this and in the end we declared this a pretty bad bug. Mind you our words not those from Microsoft. But we did find a workaround. Read More...
  • CodeCamp 2008

    Afgelopen jaar hebben we het eerste CodeCamp in Nederland georganiseerd en dat was een groot succes. De meeste deelnemers vroegen om meer, sommige zelfs om een CodeCamp per kwartaal of een heel weekend lang. Nou hebben we dat laatste nog niet gedaan maar we zijn wel aan de slag gegaan om een nieuw CodeCamp te organiseren. Als datum hebben we zaterdag 6 september gekozen. Gelukkig waren Microsoft en Class-a behulpzaam en kunnen we, net als vorig jaar, weer in het Microsoft Innovation Center in Barneveld terecht. Een mooie datum en locatie om uitgerust van de vakantie een hoop kennis uit te wisselen. Het programma staat nog niet helemaal vast, hou daar de website voor in de gaten, maar je kan er ondermeer de bekende Nederlandse sprekers verwachten. Uiteraard kan je zelf ook nog een sessie voorstellen dus als je een idee hebt voor een leuke sessie laat het dan zo snel mogelijk weten. Dus zet de datum vast in je agenda en meld je zo snel mogelijk aan op de website www.code-camp.nl . Het CodeCamp is een gezamenlijk initiatief van de SDN , de stichting DotNed en VB Central . Read More...
  • SQL Compact 3.5 on a 64 bit Windows

    SQL Compact is a great little database and highly recommended. However it was designed for use on small compact, hence its name, devices and that has some drawbacks. One of these is that it doesn't run as a 64 bits application. And by default if you create a .NET application it is compile as "Any CPU" meaning it will run as a 64 bits application on a 64 bits version of Windows. I, or I should say Ron Jacobs , ran into that using my SqlCeWorkflowPersistenceService because the sample/test application was set to the default of "Any CPU". The result is that the LINQ provider cannot load the runtime and a InvalidOperationException with message "Cannot open 'WorkflowPersistenceDatabase.sdf'. Provider 'System.Data.SqlServerCe.3.5' not installed." is the result. Now the fix is rather easy but it has to be done in the main program and that is to compile it for X86 instead of Any CPU. Do this and any application using SQL Compact 3.5 will happily run on Windows 64bit as a WOW Application. Enjoy! Read More...
  • SQL Server Compact Workflow Persistence Service updated

    I have just updated the SQL Server Compact Workflow Persistence Service to better handle deserialization issues when loading a workflow. The service now makes sure the WorkflowRuntime ServicesExceptionNotHandled is raised, something it should have done in the first place. You can download the SQL Server Compact Workflow Persistence Service from here . Enjoy! www.TheProblemSolver.nl http://wiki.WindowsWorkflowFoundation.eu Read More...
  • FaultHandlerActivity and workflow persistence

    I was just working on an issue reported against the SQL Server Compact Workflow Persistence Service I released some time ago. It turns that if you are using workflow persistence your workflow will actually be persisted to the store when an exception is caught. Now in itself not a big problem as your whole workflow needs to be serializable anyway. Except this time where is an additional exception object and when the exception itself cannot be serialized this brings the whole workflow down. In fact it brings more that just the workflow as the whole workflow runtime crashes, not good The culprit in this case was a SqlCeException which is not serializable! Don't worry about the more common SqlException because that is perfectly ok. Still something to double check as these exceptions are, by their very nature, the exceptional case and therefor less likely to be tested. Enjoy! www.TheProblemSolver.nl http://wiki.WindowsWorkflowFoundation.eu Read More...
  • Unit testing asynchronous workflow activities

    In a previous blog post I demonstrated how TypeMock allowed us to mock out the workflow runtime infrastructure and create true unit tests for a workflow activity. Now this may not seems like a big deal but because most of the classes in the workflow runtime are sealed mocking them with another mocking framework is pretty much impossible. Now you can test custom activities by wrapping them in a test workflow, creating a workflow runtime, running the workflow and inspecting the result I can hardly call this a unit test as we have to create lots of, complex, depended objects. So TypeMock really opens up some new possibilities here. But the previous examples where still pretty simple, although mocking the ActivityExecutionContext has always been considered impossible, so lets try something more complicated in the shape of an asynchronous activity. Basically an asynchronous activity is an activity that returns ActivityExecutionStatus.Executing from the Execute method indicating to the workflow runtime that it isn't done yet. The activity uses ActivityExecutionContext at a later point in time to indicate that it is done by calling the CloseActivity function. Lets take a quick look at our new activity. public partial class WriteLineActivity3 : Activity { public WriteLineActivity3() { InitializeComponent(); } public string Message { get ; set ; } protected override ActivityExecutionStatus Execute( ActivityExecutionContext executionContext) { ActivityExecutionStatus result = ActivityExecutionStatus Read More...
  • Changing the ActivityDesignerTheme on an activity

    Using an ActivityDesignerTheme is a quick way to customize the appearance of an activity in the workflow designer. But there is a gotcha Because once you applied the theme and have a workflow with the custom activity open in the designer no matter what you do changes will not be applied. I am not sure why this is but I suppose the designer caches the color scheme and doesn't see any changes made to it. Take the following activity: using System; using System.ComponentModel; using System.Drawing; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Drawing.Drawing2D; namespace WorkflowConsoleApplication4 { [ Designer ( typeof ( MyActivity1ActivityDesigner ))] public partial class MyActivity : Activity { } [ ActivityDesignerTheme ( typeof ( MyActivity1ActivityDesignerTheme ))] public class MyActivity1ActivityDesigner : ActivityDesigner { } public class MyActivity1ActivityDesignerTheme : ActivityDesignerTheme { /// <summary> /// Initializes a new instance of the MyActivity1ActivityDesignerTheme class. /// </summary> public MyActivity1ActivityDesignerTheme( WorkflowTheme theme) : base (theme) { BackColorStart = Color .LightBlue; BackColorEnd = Color .Blue; BackgroundStyle = LinearGradientMode .ForwardDiagonal; } } } Which look like this in the designer Clearly the background has a blue gradient. Now if I change the theme code to the following: public class MyActivity1ActivityDesignerTheme : ActivityDesignerTheme { /// <summary> Read More...
  • Using multiple SetState activities in a StateMachineWorkflow

    When working with state machine workflow's the SetStateActivity is one of the more important activities to use. The main reason is that is the one used to transition from one state to another. You can actually transition state in a different way as well using the StateMachineWorkflowInstance.SetState() function but the SetStateActivity is by far the most often used. One of the cool features of the SetStateActivity that may not be immediately obvious is the fact that it doesn't do the state switch immediately. Instead it saved the new target start in an internal property, named NextStateName on the StateMachineExecutionState type to be exact, and only does the state switch when the current EventDrivenActivity or StateInitializationActivity is finished. And just to be clear those are the only two activities where you can use a SetStateActivity. So the cool part is that you don't need to have the SetStateActivity right at the bottom of the EventDrivenActivity but it can be anywhere in the execution flow. Something that might make the execution logic quite a bit easier. And the second cool behavior is that you can actually execute multiple SetStateActivity objects with different TargetStateName definitions and only the last one will be executed. Again something that might make the logic quite a bit simple as you can set a default TargetStateName at the beginning of your and make changes to the target as exceptional cases arise. Both of these behaviors are especially important Read More...
  • Unit testing custom workflow activities

    Most people consider unit testing of custom workflow activities to pretty much impossible. Sure you can create a dummy test workflow containing your new activity, new up a WorkflowRuntime , create a WorkflowInstance and start it. But just think about all the dependencies here with the extra dummy workflow and the complete WorkflowRuntime with all its dependencies. Hardly a unit test for an activity but more like an integration test. Now there is nothing wrong with integration tests, they are very useful and necessary, but they do not give the speedy and dynamic test coverage you expect and need from a unit test. So is this really the case? Lets look at a few simple examples. This first example is really simple, in fact simple enough to say unrealistic but lets take a look anyway: public partial class WriteLineActivity1 : Activity { public WriteLineActivity1() { InitializeComponent(); } public string Message { get ; set ; } protected override ActivityExecutionStatus Execute( ActivityExecutionContext executionContext) { if (! string .IsNullOrEmpty(Message)) Console .WriteLine(Message); return ActivityExecutionStatus .Closed; } } This can easily be tested with a unit test like this. /// <summary> /// A test for Execute ///</summary> [ TestMethod ()] [ DeploymentItem ( "WFUnitTest1.exe" )] public void ExecuteTest() { WriteLineActivity1_Accessor target = new WriteLineActivity1_Accessor (); ActivityExecutionContext executionContext = null ; ActivityExecutionStatus Read More...
More Posts Next page »

Copyright © 2007 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us