VS Team Explorer greyed out context menu with ‘No commands available’

July 7th, 2009

This sometimes happens. While searching for an answer I came along a nice post from Stuart Preston on this problem. Visual Studio sometimes losses focus to the right source control plugin. Just select the right one and all context menu options are back in place. It worked for me!

Find the right object in your workflow instance

July 7th, 2009

When developing your workflow there are situations that changing settings of activities, at runtime, are required. Every object in your workflow can be used from within the workflow class file and adjusted to your own will. A little example:

The situations is as follows. You have added a SendEmail activity to your workflow. At runtime you have to check a webservice to retreive the right email address to send an email to. In the designer environment in visual studio you write create a method that will be called when the activity is executed during the workflow instance execution. You register the method in the Methodname property of the SendEmail activity. This hooks up the method to the SendEmail activity MethodInvoking event. Your method should look like this:

protected void SendThisEMail(object sender, Eventargs e)
{
   …
}

The SendEmail activity is declared in the private field mySendEmailActivity. Now here is the tricky part. It is most likely to create the body from the SendThisEmail like:

mySendEmailActivity.To = wouter@goedvriend.com;
mySendEmailActivity.From = somebody@goedvriend.com;
mySendEmailActivity.Body = “This is a nice body text”;

Unfortunately this does not do the trick. I started figuring out why. Is the mySendEmailActivity instantiated? It is at runtime. Why is there a problem sending the email?

This is why. Remember the SendThisEmail method is an EventHandler for the MethodInvoking event. That mechanism is asynchronuous! It sends the handle to the SendEmailActivity object in the sender object. This is quiet obvious if you know and remember. But hard to find if you think you are right by using the activity object straight forward. So it has to use the sender object to passthrough the object that raised the event. The correct code for the SendThisEmail method should be:

protected void SendThisEMail(object sender, Eventargs e)
{
    SendEmailActivity sendEmail = (SendEmailActivity) sender;
    sendMail.To = wouter@goedvriend.com;
    sendMail.From=somebody@goedvriend.com;
    sendMail.Body = “This is a nice body text.”;
}

This solved my problem with the SendEmail activity and other activities I used throughout my workflow.This is the link to the msdn page for the SendEmail activity.

State machine workflow on MOSS2007

July 7th, 2009

My problem with WF was that it had to cooperate with Sharepoint 2007 (MOSS2007). I wanted to use a state machine workflow because it has the best options for creating self supporting delimeted functionality. States within the same workflow instance can be executed over and over again.

When starting the development on WF I started reading several books and online resources. also some about Sharepoint and WF. The strange thing was that none of the books give any in depth information on the State Machine, only the Sequential workflow. This meant to me that I had to start investigating on my own here. The trial and error method suits (but not very well) in these kind of circumstances.

After 2 weeks of trying I managed to create a State Machine workflow that had 3 states, installed in the Sharepoint runtime and operates nicely. But i ran into an other problem. Here is a little on the requirements the states had to meet.

  1. Create a Task in the Sharepoint task list of the logged on user
  2. Consume the OnChange event when the Task is changed by the user;
  3. Complete the Task;
  4. Proceed to a next state. This next state could be itself again

When a workflow is activated the workflow runtime instantiates the workflow creating all the child object as well. So at runtime no new objects can be created of any workflow relative types. To make things more clear I will explain how Sharepoint keeps track of tasks created by a workflow.

Sharepoint uses correlation tokens for keeping track of things. Every correlation token has to be unique within a workflow. When configuring an workflow activity that has to add a task to the Sharepoint tasklist the developer also has to provide an so called "Owner Activity". All examples out there state that you have to put the Workflow name here. This is exactly where things start going wrong. The combination of the correlation token and the owner activty makes the sharepoint task unique. The owner activity can be seen as the context of the task. So tying the task to the workflow context makes that the task can only be created once during the execution of the workflow instance. Get the point? When executing states over and over during one workflow instance will not do the yob!

Every single example does not say anything about a different owner activity configuration. They all state to the workflow name. So after another 3 weeks of trial and error (even the method of executing workflows in workflows)Â we (a colleague and I) discovered the existance of a state context. This was exactly what we needed. So tying the Sharepoint task to state context implicates that when a state finishes the context is renewed when the state is executed again. After creating a sample this mechanism turned out to be the solution to my problem.

So when recapping this knowledge, when creating State Machine workflows on MOSS2007 and you want to create tasks in the Sharepoint tasklist, always configure the Correlation Token setting of your activity so that it has a unique name and the owner activity settings is tied to the state instead of the workflow.

Writing to the Workflow History in MOSS2007

July 7th, 2009

While working with windows workflow foundation for a couple of months step by step the puzzle comes together. We have developed quite a few different workflows and embedded them in sharepoint sites. At one moment in time with one specific workflow something strange happened. Normally when you deploy a workflow to a sharepoint site, every step in your workflow will be logged to the WorkflowHistory list in your site. With this specific workflow it suddenly stopped registring its steps in the history. We went searching and trying, nothing seemed to do the trick. No logging, so it seemed. After a while of seraching online, my collegue discovered the LogToHistoryActivity in the default toolbox. So the solution to our problem was within 150px to the left of our workflow designer screen in Visual Studio!

The lesson here is to think simple instead of letting your thoughts go the complicated way.

Custom sort order on columns in Matrix report

July 7th, 2009

Ever wanted to sort values from a set that act as columns in your matrix report? I have had such an experience. The normal sorting possibilities only give the possibility to sort ascending or descending. But what is you want to apply a custom sortorder. I have the following values (The values are actually the work item states from an agile dashboard):

- New
- In Iteration
- Working
- Test
- Rework
- Accepted

These values are part of the System_State collumn in the dataset I use. People working with Microsoft Team Foundation Server and the WorkItem mechanism of the technology will recognize the column. When adding thie set to the columns group collection of a Matrix report (Reporting Services on Microsoft Visual Studio) this set can be ordere ascending or descending, that would en up like:

Ascending: Accepted, In Iteration, New, Rework, Test, Working
Descending: Off course the other way around…..

This is not the sort order that I want in my report. I want the sort order to be like the order in the bulleted list earlier in this post. There are at least 2 options to get the job done.

Option 1:
Create a different table in your database with 2 columns, one for the State description and one with numeric values from 1 to 6 (in my case) and give the value that has to appear first the value 1. Give all the values you have the right number. Then sort the results in the dataset on the numeric column. This works fine, but only if you are able to adjust the database directly. If not, you will have a hard time getting the correct sort order.

Option 2: Let the matrix table do the sorting for you with a, by accident, found feature. This how it works. Open the "Groups" tab in the properties of the Matrix table (you will find the properties by opening the context menu on the table). In the "Groups" tab locate the "Columns" section and select the appropriate set. In my case I have add the set "States".

I assume that you are familiar with adding sets to the columns section of a Matrix table. MSDN is a good starting point. A general tutorial on creating and customzing a report is also present on MSDN.

The trick here is to get the correct sort order. In order to achieve that you have to add a sort expression for each value in your set. you can find the sort order dialog by editing (select the columns group and click the "edit button") the the column group and activate the "Sorting" tab.
The sort expression should look like "=(Fields!System_State.Value = "New") and in the direction column apply the value "descending" now I repeat the steps for all the values from the "States" set and put them in the order I want them to appear. My final expressions list looks like the picture below. This technique results in the custom order I want!

Silverlight 2.0 development with Visual Studio .NET 2008

July 7th, 2009

Last week I have started developing a Silverlight solution. After installing VS 2008, Silverlight SDK and Microsoft Expression Blend I was ready to go. The installationprocess went quite well. So that was a relief according to earlier tries…

After installing the components I started a new project in VS 2008. Also a piece of cake. I saved the solution. Off-course the big test was to open my solution in Expression Blend (March 2008 beta version). The development environment in Expression Blend is new to me just as the XAML is. I’am an "old school" webdeveloper experiencing a new environment for the first time. Creating a control is very easy. Creating it according to your wishes feels the same a discovering a brand new kitchen for the first time. Every thing is on a different spot than you are used to.

Off-course I want to re-use the user control I just created. But where is it? After some research it appears in your toolbox under user controls and then the custom category. Easy to reach when you know. This is just a simple example of struggling with new tools and envirnments. But if you want to go forward you have to investigate and discover. Finaly I succeeded in running my first Silverlight application based on the "light" version of the .NET Framework. The next challenge is to create an Silverlight application working together with a backend tied to eachother by a WCF configuration.

Setup Remote Debugging

July 7th, 2009

During my current project I want to have the ability of remote debugging a staging server. Because our development machines diver that much and the staging machine is a exact copy of the production server, it can be very usefull to setup this scenario. Orcourse these things are not done easily. I have found some articles about this that i used to make things work.

First i used this post about setting up remote debugging:

<em>Remote Debugging with Visual Studio .NET 2003:</em>

<a href="http://www.nashvs.net/ShowPost.aspx?PostID=233">http://www.nashvs.net/ShowPost.aspx?PostID=233</a>

this was not enough to get things started. From my Visual Studio i am able to connect to the debug service manager on the staging server and attach to the process i want to debug, but no breakpoint are hit. Using Google i found the second article:

<em>Recap of debugging permissions in ASP.NET</em>:

<a href="http://support.microsoft.com/kb/893658">http://support.microsoft.com/kb/893658</a>

This article mentioned something about the asp.net worker process and the processIdentity tag in the machine.config on the remote machine (XP and 2000) or set the identity in the AppPool for the right user (Windows 2003). If this isn’t enough to start things up, read the following article from MSDN:

<a name="vxtskremotedebuggingacrossmachineaccounts"></a><em>Remote Debugging Under Another User Account:</em>

 <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtskremotedebuggingacrossmachineaccounts.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtskremotedebuggingacrossmachineaccounts.asp</a>

This article describes how it is possible to setup remote debugging in a special way. Handy if your development station is not in the same domain as the server you want to debug remotely.

Hello world!

June 17th, 2009

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

Sharepoint Web Configuration Confusion

April 1st, 2007

The usual way to implement configuration settings in your website is trough a ASP.NET web.config file in your website. It can be placed in any folder in the website. When using Sharepoint Portal Server (SPS) Windows Sharepoint Services (WSS) you have to deal with several place in which web.config files exists and have to be configured.

Usually a web.config exists in the virtual server and in the layouts directory. I assume that everyone working with sharepoint technology knows what a virtual server is. If not read a SPS manual to know what I’am talking about. This layouts directory is available from all virtual servers and the web.config also off-course. The physical path of the config file looks something like:

c:\windows\program files\common files\microsoft
shared\webserver extensions\60\templates\layouts

When adding, for instance, key/value pairs or register the session state module in the httpHandler section you have to keep in mind what purpose these settings have. If you have an application available only within one virtual server and only installed in the virtual serves then you only have to update the virtual servers web.config. If you are planning to install web applications which have to operate throughout the SPS installation take care to put the right configuration settings in the right configuration file.

Adobe PDF custom document property problem

April 1st, 2007

Today my client asked me to take a look at a problem with Adobe pdf documents. These documents are items in document libraries in sharepoint team sites. When having these documents indexed through the Sharepoint crawler not any metainformation of a document is exposed bij the crawler. The documents exist in the index, but when searching for it properties like title and description are not displayed.

I developed a custom webpart application which uses the Sharepoint search webservice. When using a very handy tool (SPS Query) the documents are found but without the metainfo. When looking arround the internet i found one post that worries me a lot.

This post discusses the same problem with the metainfo from pdf documents in Sharepoint 2003 and does not come with a solution. They recommend the use of IFilter explorer by citeknet.com. This tool enables you to find out what kind of filters and extensions are living on your server machine, it did not help me any further.

So the quest fo Adobe pdf metainformation goes on..