Monday, March 2, 2009

Update Vitual Machine Additions issue

Last week I try to attach an old virtual machine (realized in Virtual PC 2004) to my Virtual PC 2007 sp1. When I try ti update the Virtual Machine Additions to the new release I recevice the following error: "Error 1714: the older version of Virtual Machine Additions cannot be removed. Contact your support group" The same error is raised up if you try to uninstall the component from "Add or Remove Program" (Panel Control -> Add or Remove Program). So, after a long googling, I succeeded in my purpose following this steps:
  • Download Windows Installer CleanUp Utility from Microsoft site,
  • Install the utility,
  • Launch "Windows Installer CleanUp Utility" (Start -> All program -> Windows Installer CleanUp Utility),
  • "Windows Installer..." shows a list of all your programs installed on your virtual system,
  • Select item "(All user) Virtual Machine Additions [your version]" like in the figure,
  • Click "Remove",
  • Click "Ok",
  • Re-run Virtual Machine Additions program installation
Now, you are able to complete successfully the setup. Note: If you install VMA from last version of Virtual PC (VirtualPC 2007 sp1), you should have this version number: 13.820. Reference: Windows Installer CleanUp Utility
kick it on DotNetKicks.com
Save to delicious 0 saves

Monday, February 9, 2009

Declarative Workflow

Today, I began to experiment on MS WF. I find very useful the possibility to load at runtime a xaml file of my personal workflow. To reach my goal I create two project with VS 2008 to test my solution:
  • A console project which is the entry point of my application;
  • A workflow library where put my custom activity and sequence workflow.
In my workflow library I add a xaml file where I put only my custom simple sequence with only one custom activity that print a "Hello world" (see the figure below). Remember that the custom activity must be tagged as [Serializable]. My xaml file hasn't the code behind because I built my workflow in declarative manner. If you take look at xml you could see:
<SequentialWorkflowActivity x:Name="Workflow1"
     xmlns:ns0="clr-namespace:MyWorkflowLibrary.Task;
Assembly=MyWorkflowLibrary, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
<ns0:HelloWorldTask x:Name="helloWorldTask1" />
</SequentialWorkflowActivity>
Note that I remove the x:Class attribute in SequentialWorkflowActivity. I do that because I haven't the compiled class in the code behind. In namespace attribute I add the reference to the assembly container of my activity, because this will be resolved at runtime. The console application "Main" looks something like this:
 static void Main(string[] args)
{
// Here, I read my xaml file containing my declarative workflow
var xmlReader =
    new XmlTextReader(
        new StringReader(
            File.ReadAllText(
                @"C:\Users\simonem\Documents\Visual Studio 2008\Projects\
                  TestWorkflow\MyWorkflowLibrary\HelloWorld.xoml")));

var runtime = new WorkflowRuntime();

runtime.StartRuntime();
runtime.WorkflowCompleted += delegate
                                 {
                                     Console.WriteLine("WorkFlow completed");
                                     Console.Read();
                                 };
try
{
    var instance = runtime.CreateWorkflow(xmlReader);
    instance.Start();

}
// Here I manage potential workflow validation exceptions
catch(WorkflowValidationFailedException wfve)
{
    var errorValidation = string.Empty;
    foreach (var error in wfve.Errors)
    {
        // StringBuilder is better...
        errorValidation += Environment.NewLine + error.ErrorText;
    }
    Console.WriteLine(errorValidation);
}
// General exceptions
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}
Console.Read();

}
Troubleshooting:
  • If during the program execution you receive an error such as "Could not deserialize object. The type 'clr-namespace:MyWorkflowLibrary.Task;.HelloWorldTask' could not be resolved. startIndex cannot be larger than length of string.Parameter name: startIndex" remember to specify the assembly reference in workflow xml code (see below):
     <SequentialWorkflowActivity x:Name="Workflow1"
     xmlns:ns0="clr-namespace:MyWorkflowLibrary.Task;
Assembly=MyWorkflowLibrary, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
  • If you couldn't compile your solution and you receive the following error "Cannot compile a markup file which does not contain declaration of the new workflow type." you must change the build action on your xaml file from "Content" to "None".
References:
kick it on DotNetKicks.com
Save to delicious 0 saves

Wednesday, February 4, 2009

TFS 2008: TF31002 error workaround...

After the setup of my new TFS server (see Install TFS 2008. The final attempt!!!), I start using TFS to share my project with other colleagues. So I follow Microsoft directives here To accomplish this goal, but when my friend trys to connect to my TFS server receive the infamous windows below:After a long and exhausting research on Google (I see that many other guys run against the same problem) I find the follow workaround:
  • Open IIS console,
  • Go to "Team Foundation Server" site, and open Authentication feature
  • Open context menu from ASP.NET Impersonation:
  • Set "Specific user" property to the account used to install your TFS server (in many other post is named TFSSetup)
Repeate the steps above also for the WSS site (in my case is the "Default Web Sites"). Remember that new TFS users must have also the permission in WSS site and in Reporting Service. To accomplish this requirement take a look to the screenshot below (IMHO is very usefull create a users group in your machine named TFS_Users and use it...):
Have a nice TFS experience ;-)
kick it on DotNetKicks.com
Save to delicious 0 saves