Saturday, September 24, 2022
  • Home

Finished the Translation on WF HOL Lab04 to VB2005

March 21st, 2007 by kenlin@HK [MVP]
Well, I start doing the translation again. I spent 2 days on this propose in the end of Jan. And I start pick it up again and try to finish it asap. Cause I found someone left message in and asking me if I will do the rest. So….I hope that I would be able to finished all HOL Labs within this month. But it is a very hard job. I wake at 5:30am(because of Jet lag after back from Global MVP Summit 2007 in Seattle), and so I still search around about Orcas, I got confuse on what Orcas acutally is. I know that it is Next VS(might be VS2007 with .NET Framework 3.5). But….I also found the Windows SDK for Vista are called Oracs_Mar07CTP in the description….hm….then….Orcas is including Windows SDK too?
Anyway, I don’t wanna get into sleep again, so I keep getting information from internet, and found, I have 3 things to do,
  1. Translation on WF HOL(Lab04 – Lab10);
  2. Translation on WF Starter Kit(still in beta and not released yet, so I think only WF team and I got it at this moment);
  3. Study Oracs, LINQ
  4. WF interact with WCF
Well, I found all I need the most is …..WF. And…I should start from basic first. So I found the first item I should choose is….(1). Then….should be (2). So I start my work on rest of Lab04. When I complete the Exercise 1 of Lab04, I cannot run it successfully. I search around and around, find many people saying that they have the same issues. I found many developers are trying to interact WF with ASP.NET2.0. But it is not a easy job but I think many companies(even in HK) will ask the developers to do so.
Well….until 3:30pm, I still cannot solve it. What happen to my VB one? C# is working and I just do the translation…..I take a rest and don’t wanna think about it any more for a short time. I start my work again at about 10pm. I found there is a MSFT guy who answer a lot from this issue in MSDN forum, so I try to send him my source code and ask him if he can help. After I sent the email for 2-5 mins, a light comes up. I try to see my workflow project, get into every State and look at the HandleExternalEvent Activity. GOD! I made mistake on the Initial State. That is why the program cannot run it. Correct it and it works. Thanks god. And then I received that MSFT guy’s email and telling me the same stupid thing I found. He is really good, within few minutes and he really do help me and found the point.
And now, it is 4:25am, all translation on Lab04 has done. Double check and the files can close. During today’s translation, I found I have made mistake in my MSMVP’s blog. I mention, if C# is programming like
         if(SomeEvent != null)
            SomeEvent(this, args);
And VB should be
         if Not SomeEventEvent is Nothing Then
            SomeEventEvent(Me, args)
         End If
But….this is not true when apply to WF’s State Machine Workflow, I have to make sure the event raise ONLY after the workflow runtime has really started. I have to change one property from the event arguments. So the code turns out like,
         if Not SomeEventEvent is Nothing Then
            args.WaitForIdle = true
            SomeEventEvent(Me, args) ‘Or “Raise Event SomeEvent(Me, args)
         End If
But then you will found out that the program will fire another exception, it is saying (Event “{1}” on interface type “{0}” for instance id “{2}” cannot be delivered). Now you have to look deep into the InnerException and you will found (“Type {0} is not marked as serializable”). But you already given the serializable Attribute to the class. Why the exception is fired? It appears every parameter going into the event must be serializable, including the sender parameter! We pass this reference, which points to our payment processing service. The workflow instance doesn’t actually need a reference to the testing service (if it needs to invoke a method on the service, it can use the CallExternalEvent activity), so we can fix this problem by leaving the sender parameter as null or Nothing. So finally, your code(with WF) will be like this,
         if Not SomeEventEvent is Nothing Then
            args.WaitForIdle = true
            SomeEventEvent(Nothing, args) ‘Or “Raise Event SomeEvent(Nothing, args)
         End If

Posted in .NET Framework | Comments Off on Finished the Translation on WF HOL Lab04 to VB2005

This entry was posted on Wednesday, March 21st, 2007 at 7:56 pm and is filed under .NET Framework. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.