In the last weeks I wrote a migration tool to migrate test cases from Rally to Team Foundation Server. This tool is deployed to a server and runs as a Windows Service.
After I made a small update to this tool suddenly my tool stopped working.
My log file gave me the following error:
|Error in Querying Work Item System.NullReferenceException: Object reference not set to an instance of an object|
This amazed me, because it has worked before and the code that I used to create the WorkItemStore has not changed.
I searched a long time and it drove me nuts. The code did not change but it did not work. Then I found a hint in a forum. There is another way of creating the WorkItemStore.
When I deployed this, it still did not work, but at least the error message was helpful.
|System.TypeInitializationException: The type initializer for ‘Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore’ threw an exception. —> System.IO.FileLoadException: Mixed mode assembly is built against version ‘v2.0.50727’ of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.|
This helped me a lot. I changed code and referenced a new assembly. An assembly for the Test Manager API. This is a .Net 4.0 assembly.
The other assemblies are still based on the .Net 2.0 framework. Mixed mode is something that is not supported out of the box. You need to change some configuration in the windows service to support this (same goes for Web)
Add this to your app.config or web.config
The attribute useLegacyV2RuntimeActivationPolicy="true" is the keyword!
When I deployed my service it worked !!