December 2006 - Posts

Some time ago I wrote an article about using the ASP.NET security providers in a WinForm application. Off course there are more usefull goodies in the System.Web namespaces to "borrow" like the Cache. In fact this is so easy that there is little point in writing an article about it. All you need to do is add a reference to System.Web and you are ready to use it.
 
Using it is real simple. Adding something to the Cache is done with "HttpRuntime.Cache.Insert(key, value)" or one of the overloads with dependencies or expiration values. Retrieving it is just as easy, just use: "HttpRuntime.Cache.Item(key)" and cast it to the right type.
 
Only one gotcha you might run into is trying to new up a Cache object and using it. In that case you will receive a System.NullReferenceException was unhandled exception with message "Object reference not set to an instance of an object.". The solution is to use it through the HttpRuntime object instead of creating your own.
 
Imports System.Web
 
Module Module1
 
    Sub Main()
        Dim key AsString = "The Key"
        Dim value AsString = "The Value"
        Console.WriteLine("The value = '{0}'", value)
        HttpRuntime.Cache.Insert(key, value)
 
        value = "Something else"
        Console.WriteLine("The value = '{0}'", value)
 
        value = CType(HttpRuntime.Cache.Item(key), String)
        Console.WriteLine("The value = '{0}'", value)
    EndSub
EndModule
 
Enjoy!
with 2 comment(s)
Filed under:
While working with WCF and updating a service reference you may see the very informative error: Exception from HRESULT: 0x80041001
Now I don't know every possible cause but in my case it occurred because I had the generated service file open and it was marked as modified. Closing the file was all that was needed to fix the problem once I realized what was causing it.
 
Good luck with WCF!
 
with 2 comment(s)
Filed under: , ,

Today I ran into a annoying difference between XOML and code based workflows. In a project I have created a custom activity with a public property. I add this activity to a state workflow and add an IfElseActivity below it. Now I want to use the previously added activity property in the declarative rule condition.

In a code based state workflow I can type “this.myCustomActivity1.TestValue == True” into the rule condition editor. The editor indicates the expression is valid and compiling the project succeeds.

However when I do the same in a XOML with code separation state workflow things work differently. I can still add the custom activity and the IfElseActivity. The first time I try to use the custom activity in the rule condition editor the doesn’t show the this.myCustomActivity1. Adding a condition of true and compiling the project makes this.myCustomActivity1 visible in the rule condition editor. Now I can add “this.myCustomActivity1.TestValue == True” and the rule condition editor indicates everything is correct. However when I compile the project produces errors that the field "myCustomActivity1" on type "WorkflowConsoleApplication1.Workflow2" does not exist or is not accessible.

Now this is a bit of a PITA as it means creating a public property for every condition I need to test and there is little sense in creating a public property for a local test Sad

 You can vote for this issue at: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=245819
 

 

with no comments
Filed under: , ,
Another VB Power Pack is released. This time it’s the Microsoft Printer Compatibility Library 1.0 that joins the previously released Microsoft Interop Forms Toolkit and the Microsoft PrintForm Component 1.0.
 
 
Enjoy!
with no comments
Filed under:

I have been a little frustrated in being unable to find a good solution for the following problem. If anyone has a good suggestion the feedback would be appreciated greatly.

 

Suppose I have a custom activity named CustomEventActivity that implements IEventActivity. The activity is used in a state workflow. This activity receives an event containing some data and saves this data so a second activity in the same EventDrivenActivity can check on the data. Something like:

protected override ActivityExecutionStatus

Execute(ActivityExecutionContext executionContext)

{

WorkflowQueuingService wqs =

 executionContext.GetService<WorkflowQueuingService>();

WorkflowQueue queue = wqs.GetWorkflowQueue(QueueName);

MyProperty = queue.Dequeue() as string;

 

return ActivityExecutionStatus.Closed;

}

 

Now I need to check on the data saved in MyProperty in a second activity in the same EventDrivenActivity. Beecause of the spawned context I can’t just use this.myCustomActivity1.MyProperty as this just returns the template activity with an empty property.

 

In a CodeActivity I can do something like:

EventDrivenActivity eventDriven;

CodeActivity code = sender as Activity;

eventDriven = code.Parent;

CustomEventActivity act1 = eventDriven.GetActivityByName(myCustomActivity1.QualifiedName, true) as CustomEventActivity;

 

Now this is cumbersome and error prone so I don’t like it Sad

But things get worse if you want to use the value in a Declarative Rule Condition. Now it needs to be a single expression and we are located a little further inside the activity tree. I would need to use: ((CustomEventActivity)((Activity)sender).Parent.Parent.Parent.GetActivityByName(myCustomActivity1.QualifiedName, true)).MyProperty

Big yikes Sad

 

Now I could just add a single property to the workflow and bind to that but in that case I would need to define extra properties on the workflow level that really have no purpose being there. Two additional problems:

  1. If I want to use XAML workflows I would need to define the properties in base class, making it unusable when users want to expand the XAML workflow in a rehosted designer.
  2. It is no longer possible to use a ReplicatorActity with ExecutionType is parallel. After all each parallel executing branch would point to the same activity.

 

with no comments
Filed under: , ,
I decided to give screen casting a try. Being Dutch I decided to make the first attempt a Dutch language video so don't bother if you don't speak the language :-)
 
Take a look at http://www.windowsworkflowfoundation.eu/taskpane3/taskpane3.html. The screen cast is about creating a TaskPane and ribbon using VSTO 2005 SE and Office 2007.
 
Any feedback both on the contents as well as the technical format such as the resolution used is welcome. BTW I used Camtasia to produce this.
 
Enjoy!
with 3 comment(s)
Filed under: , , , ,
Of course this was already in the works for quite some time but I still think its an important announcement. Using Office Open XML means a lot for software developers, not only does the XML mean we can now actually write programs that generate Office document a lot easier without using Office itself, always a big no no in a server environment. But it being a standard means we can write programs and expect the to work when the next version of Office is released. Of course the standard also means it is a lot easier to create al sorts of commercial tools so expect a nice and growing third party market for Office add-ons :-)
 
See: http://www.ecma-international.org/news/PressReleases/PR_TC45_Dec2006.htm for the official press release from Ecma.
 
Enjoy!
 
with no comments
Filed under: ,
Next week Monday I will be presenting a session on using Windows Workflow Foundation. So if you are in the Netherlands and interested in WF you really should come and attend. And if you are not interested in WF you should come and attend too because in all likelihood you are missing out on some important new development, after all there are very few serious applications that do not contains some for of workflow :-)
 
SDE
 
And besides the WF session there is a host of other sessions about al sorts of new stuff, in fact there are 6 tracks with 5 sessions each so there is plenty to choose from!
 
See you there on Monday!
 
 
 
with no comments
Filed under: , , ,
By default SQL CE doesn't run under IIS. The original plan was for the license to disallow this. There has been quite a bit of discussion about this restriction and it look like the powers that be listened. While still not fully supported there is at least a step in the right direction by enabling the product to run, previously it actively prevented you from doing so.
 
By doing an: AppDomain.CurrentDomain.SetData("SQLServerEverywhereUnderWebHosting", true)
the product will work. As it still is a single user database there are some things to watch out for but if you are in a position to do so this might be jus what the doctor ordered :-)
 
See Steve Laskers blog post for the full story.
 
Enjoy!
 
with no comments
Filed under:
The good news is, as Paul points out over here, that the SDK samples (download here) are both in C# and Visual Basic. The hands on labs where only in C# however :-( Well that has been rectified by Ken Lin who translated them to VB. You can download them from here.
 
Enjoy!
 
with no comments
Filed under: , ,