SharePoint 2010 Taxonomy Reference Issues
If you’re looking to use the new SharePoint 2010 Managed Metadata (Taxonomy) API, you will likely run into one or both of these issues. One of them is mentioned in the known issues for SharePoint 2010 Beta 2, but not in a way that’s conducive to finding the solution with Bing or Google, so I’m including it here as well as a new one I’ve stumbled across.
The first issue is that after adding the Microsoft.SharePoint.Taxonomy reference, your project will not recognize any of the taxonomy classes (e.g., TaxonomySession). The first thing that I noticed is that adding the reference to Microsoft.SharePoint.Taxonomy from the .NET reference list simply did not work. Instead, I got a reference to Microsoft.SharePoint.Taxonomy.Intl—which is obviously a different DLL.
- Broken reference to Microsoft.SharePoint.Taxonomy
To resolve this issue, I simply used the browse option and added the right DLL explicitly from: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Taxonomy.dll. I deleted the other Taxonomy reference just for clarity.
- Browsing to the Taxonomy DLL will resolve the first issue
When you add the right version, you may see the error: “’Microsoft.SharePoint.Taxonomy.dll’ or one of its dependencies, requires a later version of the .NET framework than the one specified in the project. You can change the .NET Framework target by clicking Properties on the Project menu...” You can ignore this error (you want to use .NET 3.5), it is resolved by the next solution.
The second problem is the one mentioned in the known Beta 2 issues:
“Some assemblies, such as Microsoft.SharePoint.Publishing, appear in some cases to have a dependency on an incorrect version of the System.Web.DataVisualization assembly. The incorrect reference causes build failures. If you see this problem, add a reference to the correct version of System.Web.DataVisualization on your system. If you installation is on the C drive, that assembly will be located here: C:\Program Files (x86)\Microsoft Chart Controls\Assemblies\System.Web.DataVisualization.dll”
Evidently, Microsoft.SharePoint.Taxonomy is another one of the assemblies with this issue. Fortunately, the solution is straightforward. Simply add a reference to System.Web.DataVisualization using the path above and your problems are solved.
- After fixing the Taxonomy reference and adding DataVisualization, the project compiles
[Disclaimer: This information is based on SharePoint 2010 Beta 2 and may differ from the RTM build.]