Activate() public method

Activates this instance.
Error activating context
public Activate ( ) : IDisposable
return IDisposable
Example #1
0
		public void SetUp()
		{
			m_activationContext = new ActivationContextHelper("FwParatextLexiconPlugin.dll.manifest");
			using (m_activationContext.Activate())
			{
				m_threadHelper = new ThreadHelper();
				var ui = new DummyFdoUI(m_threadHelper);
				var projectId = new ParatextLexiconPluginProjectID(FDOBackendProviderType.kMemoryOnly, "Test.fwdata");
				m_cache = FdoCache.CreateCacheWithNewBlankLangProj(projectId, "en", "fr", "en", ui, ParatextLexiconPluginDirectoryFinder.FdoDirectories, new FdoSettings());
				NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () =>
					{
						m_cache.ServiceLocator.WritingSystems.AddToCurrentAnalysisWritingSystems(m_cache.ServiceLocator.WritingSystemManager.Get("fr"));
						m_cache.LangProject.MorphologicalDataOA.ParserParameters = "<ParserParameters><XAmple><MaxNulls>1</MaxNulls><MaxPrefixes>5</MaxPrefixes><MaxInfixes>1</MaxInfixes><MaxSuffixes>5</MaxSuffixes><MaxInterfixes>0</MaxInterfixes><MaxAnalysesToReturn>10</MaxAnalysesToReturn></XAmple><ActiveParser>XAmple</ActiveParser></ParserParameters>";
					});
			}
			m_lexicon = new FdoLexicon("Test", "FieldWorks:Test", m_cache, m_cache.DefaultVernWs, m_activationContext);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Executes the background task.
		/// </summary>
		/// <remarks>This method runs in the background thread!</remarks>
		/// ------------------------------------------------------------------------------------
		private void RunBackgroundTask(object sender, DoWorkEventArgs e)
		{
			if (string.IsNullOrEmpty(Thread.CurrentThread.Name))
				Thread.CurrentThread.Name = "Background thread";

			m_Exception = null;
			m_RetValue = null;

			ActivationContextHelper activationContext = null;
			IDisposable activation = null;
			try
			{
				if (MiscUtils.RunningTests)
				{
					activationContext = new ActivationContextHelper("FieldWorks.Tests.manifest");
					activation = activationContext.Activate();
				}
				m_RetValue = m_backgroundTask(this, m_parameters);
			}
			catch (Exception ex)
			{
				Debug.WriteLine("Got exception in background thread: " + ex.Message);
				m_Exception = ex;
			}
			finally
			{
				if (activation != null)
					activation.Dispose();
				if (activationContext != null)
					activationContext.Dispose();
			}
		}