Can't Open SPSite - FileNotFoundException

301 Views Asked by At

So I try to access the TermStore of my Sharepoint 2013. I try to do it like this:

        SPSecurity.RunWithElevatedPrivileges(() =>
        {
            var site = new SPSite(GeneralConstants.TermStoreUrl);

            try
            {

                // Get a TaxonomySession from the site
                TaxonomySession session = new TaxonomySession(site);
                TermStore termStore = null;
                // Get a TermStore from the session
                if (session.TermStores != null && session.TermStores.Count > 0)
                {
                    termStore = session.TermStores[0];
                }

                if (termStore != null)
                {
                     //... do stuff in TermStore

The Problem is that as soon as I create the SPSite, I get a FileNotFoundException. Whats the problem here? When I check the URL in the browser it works all fine and the User under which the application runs, it's a webservice by the way, has full control on the site.

Thanks for help Greets

2

There are 2 best solutions below

0
On BEST ANSWER

thanks for the answers but I found the mistake. I used the Sharepoint.Taxonomy Namespace instead of Sharepoint.Client.Taxonomy

Now I works fine.

0
On

Have you tried accessing the DefaultSiteCollectionTermStore property of your TaxonomySession?

var session = new TaxonomySession(site);
TermStore termStore = session.DefaultSiteCollectionTermStore;

Also, I use PowerShell in an SP Management Window to debug my Taxonomy code logic. It helps a lot.