Home » Sharepoint 2010

Taxonomy Termstores online/offline



I have created 2 groups on Managed Metadata Service. I've created some TermSets.

In a .NET application I can connect to sharepoint admin site using SPSite, but when I ask for TermStores the store.count is allways == 0, but I am sure they really exist.



using (SPSite site = new SPSite(url))
     TaxonomySession session = new TaxonomySession(site);
     TermStore store = session.TermStores["Managed Metadata Service"];



José Cruz


5 Answers Found


Answer 1

are you tring to access admin  site URL??

I think you have to access Managed Metadata service  application URL to get the store  items..


Answer 2

Exactly what are you not being able to access? The termstore  or the TermSets within the TermStore?

The small code sample you provided, if it's working as intended, will store  your termstore in the store variable. To access your termSets from there, try the folloing:

TermCollection myTermCollection = store.Groups[YourTermGroup].TermSets[YourTermSet].GetAllTerms();


Answer 3

The problem I'm trying to figure out its that I already have  to created  1 termstore  with some groups  and terms but when I try to get these groups/terms, from an outside web site, the session  Termstore collection has count  == 0, and the offline property has 1 termstore.

To get the terms should I connect  to administration site  or should I use a regusilar site collection?



José Cruz


Answer 4

The first thing I'd confirm is that your managed  metadata service  is running and that it is actually called "Managed metadata  Service"

I don't see anything wrong with your code.

using (SPSite site  = new SPSite("http://localhost/")) 
//Instantiates a new TaxonomySession for the current site. 
TaxonomySession session  = new TaxonomySession(site); 

//Instantiates the connection for the current session 
TermStore termstore  = session.TermStores["Managed Metadata Service"]; 

// Write out the names of the term stores to a label 
Label1.Text = “”; 
foreach (TermStore termstore in session.TermStores) 
Label1.Text += termstore.Name.ToString() + " … "; 

// Write the name of the term store  to a label 
Label1.Text += " Finished"; 


Answer 5

It's also possible that it is a permissions issue.  In the same way that the user running a console application  has to have database access to the sharepoint  database, the user running the console application has to have permissions to the back end  service  application.  (Not to the termstore  itself, but rather to the communication channel between the WFE and the application server).  You can check this by looking at the permissions of the service application itself in central admin.  It is probably currently configured to have a farm claim only.





<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure