Once you have imported a list of work items in excel from a team project in TFS, the excel file always proposes work items from the same team project. It does not seem possible to obtain the "connect to TFS" popup window again, where you choose the team project. This is because the connection is stored as a custom property in the excel file.
The answer is to delete all custom properties from the file. Go to the main menu and then: Prepare / Properties / Document Properties / Advanced Properties / Custom. Delete all "VS Team System Data DO NOT EDIT" properties (the content is encrypted). Do NOT save the file. If you save it, the properties are created again! Just go to the Team menu and choose "New List": you will now be prompted to choose a team project.
If you need to save the file (you want to keep it without the TFS connection in it), follow the instruction given by Buck Hodges here. Before removing the properites, you have to deactivate the TFS excel add-in.
Up to now I haven't explained what my mobile test application does. The main thing I wanted to test was calling a WCF service. If you use .NET CF 3.5 WCF will be available in your application to make the call but you can also call the service as "web service" (asmx)
(1) Calling the service as ASMX
In you Smart Device Application project just do "Add Web Reference", enter the url of the service (no "mex" part but with final /, like this: http://server:port/Design_Time_Addresses/WcfService/Service1/) and your are done.
This is the code I use in the device application to call the web service:
Service1WebReference.Service1 svc = new Service1WebReference.Service1();
IWebProxy proxyObject = new WebProxy(this.proxyAddress, true);
proxyObject.Credentials = System.Net.CredentialCache.DefaultCredentials;
svc.Proxy = proxyObject;
string response = svc.GetData(i, true);
I had to specify the proxy address otherwise it would not work. The first time I call the service I get prompted for the credentials.
(2) Calling the service as WCF
The first thing you will notice is that in the Smart Device Application project, there is not option to "Add Service Reference". GRRRR ... You need to install the Power Toys for the Microsoft .NET Compact Framework. Then, you can use the NETCFSvcutil utility to generate the proxy code. Like this:
"C:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\bin\NetCFSvcUtil.exe" http://server:port/Design_Time_Addresses/WcfService/Service1/
The utility generates two files (Service1.cs and CFClientBase.cs) that you have to add to your project.
This is the code I use in the device application to call the WCF service:
Service1Client client = new Service1Client();
string response = client.GetData(i);
Remarks
Notice that you have to use your machine IP as server name and not "localhost". Otherwise, your smart device will not be able to locate the service.
Several other blogs explain how to connect the emulator and your desktop machine: for example, here. (This is for Pocket PC or Smartphone emulators that are proviced by the SDK; if you can to use the Windows CE 5.0 emulator, read this and see my previous blog post).
After setting up the development environment, I started coding a simple application. Visual Studio does not provide a Windows CE 5.0 emulator (only a device - which means that it tries to connect to a real device and I don't have one), so I chose to develop a Windows Mobile 5.0 Pocket PC application.
(1) I first created a Smart Device Console Application. It built and deployed ok, but when running I didn't see any console! I think this is due to the fact that there is no cmd.exe in the emulator.
(2) I then created a Smart Device Application (Windows Forms). This is the kind of application I will have to develop later, anyway. Build and deploying where fine and the form appeared in my emulator:

Nice!
After that, I started wondering what the difference was between Windows Mobile 5.0 Pocket PC and Windows CE 5.0. Wikipedia is pretty good for this kind of questions: check it out here. So, they are pretty close (Windows Mobile 5.0 Pocket PC is built on top of Windows CE 5.0) but not the same. Besides, the Pocket PC emulator screen did not look like the Datalogic Memor screen:


Better check that my application works on Windows CE 5.0, then. How?
(1) Download the Windows CE 5.0 emulator from here.
(2) Launch it from the command line (not from the start menu link, otherwise you will not be able to specify any options for network connections):
C:\Program Files\Windows CE 5.0 Emulator>Emulator_500.exe /CEImage nk.cem /Ethernet virtualswitch
(3) Connect to the emulator: I followed the instructions here. Just a few remarks:
- the <CPU> of the emulator is x86;
- the emulator does not have a command prompt (or I didn't find it), so I just double clicked on the exes to run them;
- you can read the IP address by double clicking on the network link icon on the taskbar;
- you can copy files from your machine to the emulator by creating a shared folder (see emulator file menu) which is accessible through the "storage card" in the emulator windows explorer.
Once I had the emulator connected, I deployed an application (usual method = F5 + select Windows CE Device) built using a Smart Project Device Application project for Windows CE 5.0.
But ... what about my initial Pocket PC application? Would it deploy in the Windows CE emulator? It did!
I created a CAB (deployment project for smart device apps) for the Pocket PC application. I copied on the Windows CE emulator and double clicked it: it installed and run fine!
I might have to develop an application for a mobile scanning device and I have been playing around with the .NET mobile components in preparation. Not easy at all: the documentation is not very clear and there are lots of different components/versions. Here are some of the problems I encountered and how I solved them.
My constraints:
a) My development environment is Windows Vista + VS 2008 Team System.
b) The device will probably be Datalogic Memor which runs Windows CE 5.0. This means I need to install Windows Mobile 5.0 SDK - the documentation says that it only supports VisualStudio 2005 and Windows XP and that it requires ActiveSync 4.0.
c) I want to develop with the .NET Compact Framework 3.5 in order to use WCF. This was installed already on my machine.
So, will all of this work toghether on Vista? Well, it did (unexpectedly).
The only quirk is that you cannot run ActiveSync 4.0 on Vista. You have to install Windows Mobile Device Center instead.
I regularly get this problem. The "Find in files" function of VisualStudio (2008!) stops working. Whatever I search for it always says "No files were found to look in. Find was stopped in progress". It is very annoying.
Since I have only found one other blog that mentions it and gives a solution (here - thank you!), I'm going to reproduce it.
Solution: press Control + Scroll Lock (yes, it doesn't make much sens but it works).
There is a well-known issue with WPF RadioButton controls with data binding: when a radio button is unchecked the data binding is not undone. For example, suppose you have the following two radio buttons in the same group linked to a the "IsSuccess" (of type bool?) attribute of an object:
<RadioButton
Grid.Row="0"
Grid.Column="0"
GroupName="rbGroup"
Margin="8,0,0,0"
VerticalAlignment="Center"
Content="Success"
x:Name="rbSuccess"
IsChecked="{Binding Path=IsSuccess, Mode=TwoWay, Converter={StaticResource nullableBooleanConverter}}" />
<RadioButton
Grid.Row="0"
Grid.Column="1"
GroupName="rbGroup"
Margin="8,0,0,0"
VerticalAlignment="Center"
Content="Failure"
x:Name="rbFailure" />
When you check the rbSuccess radio button, the IsSuccess field becomes "true", but when you check on the rbFailure radio button (and thus uncheck the rbSuccess one), the IsSuccess field is still true!
The problem is discussed here. There are several solutions. This blog explains one (using a control template). Another popular one is to use a ListBox restyled as a radio button. However, this causes other problems such as being unable to scroll past the radiobuttons (they are really a listbox, so scrolling is done inside the list).
The solution I have found is to put each radio button in a different group and link their checked/unchecked values via the converter. Like this:
<RadioButton
Grid.Row="1"
Grid.Column="0"
GroupName="rbGroupSuccess"
Margin="8,0,0,0"
VerticalAlignment="Center"
Content="Success"
x:Name="rbSuccess"
IsChecked="{Binding Path=IsSuccess, Mode=TwoWay, Converter={StaticResource nullableBooleanConverter}, ConverterParameter=true}" />
<RadioButton
Grid.Row="1"
Grid.Column="1"
GroupName="rbGroupFailure"
Margin="8,0,0,0"
VerticalAlignment="Center"
Content="Failure"
x:Name="rbFailure"
IsChecked="{Binding Path=IsSuccess, Mode=TwoWay, Converter={StaticResource nullableBooleanConverter}, ConverterParameter=false}" />
And here is the converter:
[ValueConversion(typeof(bool?), typeof(bool))]
public class SuccessConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool param = bool.Parse(parameter.ToString());
if (value == null)
{
return false;
}
else
{
return !((bool)value ^ param);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
bool param = bool.Parse(parameter.ToString());
return !((bool)value ^ param);
}
}
Notice the converter parameter. Its role is to make sure that I get opposite values for the two radio buttons (when one is true, the other is false).
value
(IsSuccess) |
param |
result
RadioButton.IsChecked = !(value ^ param)
|
| true |
true |
true |
| false |
true |
false |
| true |
false |
false |
| false |
false |
true |
(^ is the XOR operator in C#)
Technorati Tags:
WPF,
RadioButton
Suppose you have three tables in your database where one of them specifies a many-to-many relationship between the other two (example from AdventureWorks):

Suppose also that you have a method such as GetVendors(int productID) that will retrieve all the vendors for a given product through the ProductVendors table (that is , the many-to-many table).
Now, if this method is exposed via a WCF service, when your client calls it you will see an exception like this one:
- "System.ServiceModel.CommunicationException was unhandled. An error occurred while receiving the HTTP response to http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details."
And the subsequent inner exception messages:
- "The underlying connection was closed: An unexpected error occurred on a receive."
- "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
- "An existing connection was forcibly closed by the remote host"
What the ... is going on? This is a seralization problem (yes, the exception message is not that clear). To test the serialization of your data I recommend the following test (from here):
Service1 svc = new Service1();
List<Vendor> lv = svc.GetVendors(319);
object dto = lv[0];
DataContractSerializer ser = new DataContractSerializer(typeof(Vendor));
FileStream writer = new FileStream(@"C:\Temp\" + dto.GetType().Name + ".xml", FileMode.Create);
ser.WriteObject(writer, dto);
writer.Close();
When running the code above, I get a clearer exception mentioning serialization:
- "System.Runtime.Serialization.SerializationException: Object graph for type 'WcfServiceLibrary1.ProductVendor' contains cycles and cannot be serialized if reference tracking is disabled."
If you then check the XML file that this test created for the Vendor object you will see it is huge and broken. The problem is that the Vendor object contains a reference to the one or more Product objects (linked through the ProductVendor table) which contain a reference to one or more Vendors which contain references to Prodcuts and so on ... An infinite cycle of references is being created. WCF does not realize that these references point to the same object and it serializes each reference (eventually throwing an exception).
There is a great post (http://blogs.msdn.com/sowmy/archive/2006/03/26/561188.aspx) about how to preserve object references in WCF. But if you are looking for a less complicated solution you can just open the *.dbml file, right click, select 'Properties' and choose 'Seralization Mode' = 'Unidirectional'. As the name indicates, serialization only goes in one direction: from a product to a vendor but not back to products (or from a vendor to a product but not back to products).
Without unidirectional serialization you could do this:
Vendor[] vendors = svc.GetVendors(319);
foreach (Vendor v in vendors)
{
Console.WriteLine(v.Name);
foreach (ProductVendor pv in v.ProductVendors)
{
Product p = pv.Product;
foreach (ProductVendor pv2 in p.ProductVendors)
{
Vendor v2 = pv2.Vendor;
// and so on
}
}
}
With unidirectional serialization you can only get as far as this:
Vendor[] vendors = svc.GetVendors(319);
foreach (Vendor v in vendors)
{
Console.WriteLine(v.Name);
foreach (ProductVendor pv in v.ProductVendors)
{
int prodID = pv.ProductID;
}
}
Just to clarify the different tools that you can use to update/recreate the Team Foundation Server warehouse (relational database and OLAP cube).
Warehouse Web Service
You can browse and invoke it here (always locally from TFS): http://localhost:8080/Warehouse/v1.0/warehousecontroller.asmx
The Run operation will launch processing of the warehouse (you can check the status of the warehouse with the GetWarehouseStatus operation: it goes from ProcessingAdapters, ProcessingOlap and finally Idle). Processing of the warehouse means (1) pulling data from the operational stores (source control, work items, builds) to the data warehouse relational database, and (2) processing the cube to aggregate the data from the relational database.
TFSServerScheduler
Windows service that signals the warehouse web service to go aggregate data and process the cube. This windows service calls the above warehouse run operation at regular intervals.
To find out when was the last time the scheduler called the warehouse to process, browse to %ProgramFiles%\Microsoft Team Foundation Server 2005\TfsServerScheduler. The xml file in that directory will contain the last time warehouse processing was attempted.
In Team Foundation2008, the scheduler is called "Visual Studio Team Foundation ServerTask Scheduler".
Documentation: http://msdn.microsoft.com/en-us/library/ms252450(VS.80).aspx
Cube processing
You can also process the cube manually from the SQL Server Management Studio. This will only perform the second step above, so if new data has not been transfered from the operational stores to the data warehouse relational database, you will not see any changes.
Setupwarehouse.exe
You can find this tool here: %ProgramFiles%\Microsoft Team Foundation Server 2005\Tools
It is used to rebuild the OLAP schema and cube or the relational database. This means that it will delete all the data in the TfsWarehouse database and cube. You will neeed to run the warehouse web service afterwards in order to recover
Documentation: http://msdn.microsoft.com/en-us/library/ms400783(VS.80).aspx
I have noticed that af'ter running Setupwarehouse.exe to rebuild the relational database, some fields are missing. This concerns the Microsoft_VSTS_* fields in the Current Work Item table, for example. As a consequence, some measures are missing from the Team System cube (Current Work Item | Remaining Work, for example). After running the warehouse web service (that pulls data into the relational database) they reappear ...
One of my main tasks now that I'm back at work is to migrate our TFS from 2005 to 2008. Our main concern is with process templates. We went to quite a lot of trouble to create our own process template and we do not want to lose that work.
I posted a question on MSDN forums about customized process templates migration without much success. So, I decided to dive in on our test environment and see what happens.
Test procedure:
- Prepare a test machine with Windows Server 2003, TFS2005, VisualStudio 2008 and WSS 2.0.
- Install MyCustomTemplate on TFS2005 in test machine.
- Create a team project with MyCustomTemplate.
- Used TFS to TFS migration tool to migrate a medium-size project from the production TFS to this test TFS (to the team project created in step 3). The tool did not work very well and only part of the source code was migrated (for work items, it worked fine).
- Backup the project portal (see http://technet.microsoft.com/en-us/library/cc288330.aspx) from our TFS 2005 and restore on test TFS2005.
- Updgraded test machine WSS2.0 to WSS3.0. This step is not mentioned in upgrade section of the TFS installation guide! You need to follow the steps under the "Install SharePoint Products and Technologies onWindows Server" section (also explained here). Notice that before running the "Sharepoint Products and Technologies Configuration Wizard", you need to run the prescan tool on all your sites (click help link at the beginning of the wizard for details).
- Upgraded test machine to TFS2008.
Here is a summary of what happened with process templates:
- On TFS 2005, the out-of-the-box templates (MSF4Agile and MSF4CMMI) are version 4.0.
- On TFS 2008, the out-of-the-box templates (MSF4Agile and MSF4CMMI) are version 4.2.
- After migrating, TFS 2008 contained (besides MSF4Agile and MSF4CMMI v4.2) the process templates available in my TFS 2005 (even those not used, customized or not).
- Since the templates were migrated, there was no loss of work items.
- The source code was migrated correctly, including the version control history.
- The project portal was migrated to WSS 3.0 (all content was kept). Of course, given that the Sharepoint template for the project was customized it still look very "WSS 2.0". There is no need to create a WSS 3.0 template for your custom process template before upgrading.
- The builds were also fine. Besides, when using VisualStudio and Team Explorer 2008, the "New build definiton" is now available (with TFS2005 it was greyed).
- The reports were migrated correctly, except for a custom one that didn't work anymore (there was an error in the report - no fault of the upgrade).
Good migration y'all!
I'm back after maternity leave!

It's good to be working again, but I'm not getting much sleep so it's pretty hard.
Here is a little script I find useful. It drops all tables, views and stored procedures in a database.
exec sp_MSforeachtable 'DROP TABLE ? PRINT ''? dropped'' '
GO
/* Drop all non-system stored procs */
declare @name varchar(128)
declare @SQL varchar(254)
SELECT @name = (select top 1 name FROM sysobjects WHERE type = 'P' And category = 0 order by name)
while @name is not null
begin
select @SQL = 'drop procedure [dbo].[' + rtrim(@name) +']'
exec (@SQL)
print 'Dropped :' + @name
SELECT @name = (select top 1 name FROM sysobjects WHERE type = 'P' And category = 0 and name > @name order by name)
end
go
/* Drop all views */
declare @name varchar(128)
declare @SQL varchar(254)
SELECT @name = (select top 1 name FROM sysobjects WHERE type = 'V' And category = 0 order by name)
while @name is not null
begin
select @SQL = 'drop view [dbo].[' + rtrim(@name) +']'
exec (@SQL)
print 'Dropped :' + @name
SELECT @name = (select top 1 name FROM sysobjects WHERE type = 'V' And category = 0 and name > @name order by name)
end
go
Please, go ahead to improve it. I'm sure it is far from perfect.
Technorati tags:
SQL Server
It has been a while since I last posted, but I haven't stopped working :) I am currently on a project involving WPF and WCF. While I am not a big fan of WPF, but I quite like WCF.
During the development of our project we run into a very annoying problem with WCF. After some help from Microsoft, we found a solution at last.
The problem is very easy to describe. On the one side, we have a WCF service running. On the other side, we have a client with a reference with to this service. Now and then, we need to update the service reference (because the service includes new features, for example). You can do this with svcutil or by right clicking on the reference in VisualStudio and choosing the "Update Service Reference" option.
One day, when updating the reference (with svcutil) we got this message:
Error: Cannot obtain Metadata from http://localhost:8000/businessservice/service/mex
The maximum nametable character count quota (16384) has been exceeded whilereading XML data. The nametable is a data structure used to store strings encountered during XML processing - long XML documents with non-repeating element names, attribute names and attribute values may trigger this quota. This quota may be increased by changing the MaxNameTableCharCount property on the XmlDictionaryReaderQuotas object used when creating the XML reader.
After several Google searches, I thought this could be solved by increasing the reader quotas parameters for the metadata exchange binding. This implied some minor changes in the service config file since the the mexBinding configuration section does not provide any properties: you have to use a wsHttpBinding without any security. This is explained here and Michele Leroux Bustamante (an expert on WCF) even provides a couple of samples (config-based sample here, and code-based sample here).
However, this did not help at all. Even setting the reader quotas to the maximum possible values made no difference at all. In the end, Microsoft told me what was wrong: the message refers to the svcutil reader quotas not the service ones! Svcutil has a limit on how much metadata it can read. This limit can be changed with a config file.
The solution is to create a config file for svcutil (see below) and place it in the same folder as the tool. Next time you run svcutil, the config file values will be taken into account.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="MyBinding">
<textMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint binding="customBinding" bindingConfiguration="MyBinding"
contract="IMetadataExchange"
name="http" />
</client>
</system.serviceModel>
</configuration>
The MSDN WCF samples contain an example of creating this config file, although the main issue is a different one (how to configure svcutil to fetch metadata from a custom endpoint), so it wasn't so obvious to make the connection.
Technorati tags:
WCF,
svcutil
I will be a speaker at the Micrsoft "Enterprise & Development Summit 2007" in Luxembourg on June 12th. This is equivalent to the Belgian DevDays or the French TechDays. You can find the agenda and details here (in French).
My session is about Team System. I will probably give a general overview and a few short demos since there haven't been many event on VSTS in Luxembourg before.
This is my first (and hopefully not last) time as a speaker. Let's hope I don't get too nervous! :)
This week we need to choose the most appropriate communication technology for one of our projects.
The project constraints are the following:
- .NET on both client and server
- client and server on same LAN
- A lot of information to be passed from server to client and vice-versa
- Performance is important
- Typed DataSets will be used on server side
- Presentation layer is developed with WPF
- Security is needed (sensitive or confidential data)
The options we have are the following:
- ASMX Web Services
- .NET Remoting
- WCF
I clearly favour option 3. First, given that this is considered a .NET 3.0 project (the presentation layer will be developed in WPF), I prefer to be consistent and use WCF. Second, the .NET Remoting option is not really an option. We have no experience with it and its future does not seem promising (given the arrival of WCF). If we have to learn something new, we might as well go for WCF.
The advantages of the ASMX Web Service option is that we have a lot of experience with it. However, WCF offers better performance. Given the amount of data that will need to be transferred, I am worried about performance. This MSDN paper compares the performance of WCF with existing technologies. The conclusions are the following:
- WCF (basicHttpBinding) is 25%-50% faster than ASMX Web Services
- WCF is approximately 25% faster than .NET Remoting
So, now within WCF, what are our options?
- basicHttpBinding : Basically the equivalent of ASMX Web Services in .NET 3.0
- wsHttpBinding : Web Services implementing WS-Security. They offer message-level security: authentication, encryption and signing.
- netTcpBinding: The "equivalent" of .NET Remoting in .NET 3.0, with the advantage that it is easier to code (given the standardization of all communication techniques)
For a table comparing the different bindings, here or this MSDN article.
I have not been able to find a Microsoft article comparing the performance of the different bindings (besides this one) but this is what I have picked up from different blogs and forums.
- netTcpBinding should be the fastest, given the binary serialization (vs. Text in basicHttpBinding). However, you should we aware of their different default settings when comparing them. netTcpBinding and wsHttpBinding both have security enabled by default (at transport and message level respectively), and the later has ReliableSessions turned on (source: here and here). I read somewhere (sorry ... lost the URL) that it is 25%-50% faster than basicHttpBinding.
- basicHttpBinding gives pretty good performance compared to ASMX Web Services and, given that there is no security, even compared to wsHttpBinding and netTcpBinding. A couple of extra tips to increase its performance even more:
- do not send the DataSet schema
- use MTOM encoding instead of Text ("MTOM is a mechanism for transmitting large binary attachments with SOAP messages as raw bytes, allowing for smaller messages")
In my opinion, netTcpBinding is a very good option for us given its good performance and security options. On the other hand, it does not respect the tenets of SOA. But ... do we really need SOA? We are dealing with an application that will be deployed inside a LAN and where both client and server are implemented in .NET. Moreover, if we are going to send typed DataSets from server to client (very probable), we have already broken the tenets of SOA.
As for security options in netTcpBinding that might reduce the performance advantage, we can go for the lightest option which is transport security (source: here).
I don't think basicHttpBinding with MTOM encoding is good option for us because MTOM is particularly interesting when sending large binary items (such as pictures, videos, etc.): "the MTOM standard allows for externalizing large data elements that are contained in a message and to carry them with the message as binary data without any special encoding" (source: MSDN). And not sending the DataSet schema reduces message size significantly only when few data is sent. As the message contains more data, the proportion of space taken up by the schema drastically diminishes.
The wsHttpBinding is very interesting if you need to implement the WS-* standards, which is not our case. Admittedly, you can also use wsHttpBindings if you want Web Services (to be SOA compliant) and you need full security. But the whole WS-* paraphernalia clearly impacts performance ...
To finish up, just a link to one of the leading WCF experts: Michele Leroux Bustamante (she must have some Spanish blood with a surname like that!)
Technorati tags:
WCF,
Indigo,
Web Services
While preparing a POC with BizTalk 2006 and the accelerator for HL7 1.3, I realized there is a little error in the end-to-end tutorial (also in <drive>:\Program Files\Microsoft BizTalk Accelerator for HL7 1.3\SDK\End-to-End Tutorial).
In the "TutorialSampleInstance.txt" the name of the source (MSH3) is "ADTSystem", while the name of the party in both BizTalk Administration and BTAHL7 is "Tutorial_ADTSystem". The consequence is that no ACK or RX messages are generated.
To solve it, just change the name of the MSH3 in "TutorialSampleInstance.txt" to "Tutorial_ADTSystem".