title: Sharepoint 2013 - Taxonomy- Microsoft.SharePoint.Taxonomy.TaxonomySession.GetTaxonomySession”
body: <p>I am updating manage meta data field using C#.
  Following is code to get TermId for term.</p>
  
  <pre><code>        string termId = string.Empty;
  
          try
          {
              TaxonomySession tSession = TaxonomySession.GetTaxonomySession(CC);
              TermStore termStore = taxonomySession.GetDefaultSiteCollectionTermStore();
              TermSet tset = ts.GetTermSet(termSetId); // I have proper Guid here, checked this in SharePoint 2013 server.
  
              LabelMatchInformation lmi = new LabelMatchInformation(CC);
  
              lmi.Lcid = 1033;
              lmi.TrimUnavailable = true;
              lmi.TermLabel = "xyz"; //Name of the term.
  
              TermCollection termMatches = tset.GetTerms(lmi);
  
              CC.Load(tSession);
              CC.Load(ts);
              CC.Load(tset);
              CC.Load(termMatches);
              CC.ExecuteQuery();
  
              if (termMatches != null &amp;&amp; termMatches.Count() &gt; 0)
                  termId = termMatches.First().Id.ToString();
          }
          catch (Exception ex)
          {
              var d = ex.Message;
          }
  
          return termId;
  
      }
  </code></pre>
  
  <p>But I am getting exception as: 
  “Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null. \"GetDefaultSiteCollectionTermStore\r\nMicrosoft.SharePoint.Taxonomy.TaxonomySession.GetTaxonomySession”.</p>
  
  <p>I have tried to load manually from Sharepoint2013, it works fine there.
  Is there anything missing ?
  Thanks for help..</p>