title: Unity: The type name or alias x could not be resolved. Please check your configuration file and verify this type name
body: <p><strong>Error code</strong> : </p>
  
  <pre><code>The type name or alias UnitOfWorkFactory could not be resolved. 
  Please check your configuration file and verify this type name.
  </code></pre>
  
  <p>I'm scraping google results / trying to debug for 2 days now, and I didn't find any solution yet.</p>
  
  <p>Mention that "ApplicationService" is being resolved.</p>
  
  <ul>
  <li>I verified the names of assemblies and namespaces many times</li>
  <li>I already tried this concepts in the config file: <a href="https://stackoverflow.com/a/18671286/3264998">https://stackoverflow.com/a/18671286/3264998</a> , and other concepts.</li>
  <li>I verified the connection to the database.</li>
  <li>I tried debugging mode in VS without any succes.</li>
  <li>Probably some other stuff that I don't remember right now.</li>
  </ul>
  
  <p>Bellow you have my code, hope it's enough. If there is any other file/info that I've omitted I apologies and I will edit the post immediately.</p>
  
  <p><strong>IApplicationService.cs</strong></p>
  
  <pre><code>using System.Collections.Generic;
  using Abc.Project.Domain.Model.DTO;
  
  namespace Abc.Project.Application.Interfaces
  {
      public interface IApplicationService
      {
          void AddFile(FileDTO fileDTO);
      }
  }
  </code></pre>
  
  <p><strong>ApplicationService.cs</strong></p>
  
  <pre><code>using System.Collections.Generic;
  using AutoMapper;
  using Microsoft.Practices.Unity;
  using Abc.Project.Application.Interfaces;
  using Abc.Project.Domain.Model.DTO;
  using Abc.Project.Domain.Model.Poco.Entities;
  using Abc.Project.Domain.Repository.UnitOfWork;
  using Abc.Project.Domain.Unity;
  
  namespace Abc.Project.Application.Services.Global
  {
      public class ApplicationService : IApplicationService
      {
          public void AddFile(FileDTO fileDTO)
          {
              File file = new File
              {
                  Id = fileDTO.ID,
                  FileObs = fileDTO.FileObs,
                  Ind = fileDTO.Ind,
                  Levels = fileDTO.Levels,
              };
  
              using (var uow = IoC.Container.Resolve&lt;IUnitOfWorkFactory&gt;().Create())
              {
                  uow.Context.File.Add(file);
                  uow.Commit();
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>IUnitOfWorkFactory.cs</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace Abc.Project.Domain.Repository.UnitOfWork
  {
      public interface IUnitOfWorkFactory
      {
          IUnitOfWork Create();
      }
  }
  </code></pre>
  
  <p><strong>UnitOfWorkFactory.cs</strong></p>
  
  <pre><code>using System.Data;
  using System.Reflection;
  using FluentNHibernate.Cfg;
  using FluentNHibernate.Cfg.Db;
  using NHibernate;
  using NHibernate.Tool.hbm2ddl;
  using Abc.Project.Domain.Repository.UnitOfWork;
  
  namespace Abc.Project.DataAccess.NHibernate.UnitOfWork
  {
      public class UnitOfWorkFactory : IUnitOfWorkFactory
      {
          private static ISessionFactory CreateSessionFactory()
          {
              return Fluently.Configure()
                  .Database(MsSqlConfiguration.MsSql2008
                  .ConnectionString(c =&gt; c.FromConnectionStringWithKey("FilesDB"))
                  )
                  .Mappings(m =&gt; m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
                  .ExposeConfiguration(cfg =&gt; new SchemaExport(cfg)
                  .Create(false, false))
                  .BuildSessionFactory();
          }
  
          public IUnitOfWork Create()
          {
              UnitOfWork UnitOfWork = new UnitOfWork(CreateSessionFactory().OpenSession());
              UnitOfWork.BeginTransaction(IsolationLevel.ReadCommitted);
              return UnitOfWork;
          }
      }
  }
  </code></pre>
  
  <p><strong>App.config</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/&gt;
  
    &lt;/configSections&gt;
  
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;connectionStrings&gt;
      &lt;add name="FilesDB" providerName="System.Data.SqlClient" connectionString="server=SP2010;database=FilesDB;User ID=sa;Password=password;"/&gt;
    &lt;/connectionStrings&gt;
    &lt;unity xmlns="http://schemas.microsoft.com/practices/2010/unity"&gt;
      &lt;typeAliases&gt;
        &lt;!-- Lifetime manager types --&gt;
        &lt;typeAlias alias="singlecall" type="Microsoft.Practices.Unity.TransientLifetimeManager, Microsoft.Practices.Unity"/&gt;
        &lt;typeAlias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity"/&gt;
        &lt;typeAlias alias="external" type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager, Microsoft.Practices.Unity"/&gt;
        &lt;typeAlias alias="percall" type="Abc.Project.Domain.Unity.StaticPerCallLifeTimeManager, Abc.Project.Domain.Model"/&gt;
  
        &lt;!-- SERVICE APPLICATION INTERFACES--&gt;
        &lt;typeAlias alias="IApplicationService" type="Abc.Project.Application.Interfaces.IApplicationService, Abc.Project.Application.Interfaces"/&gt;
  
        &lt;!-- DOMAIN INTERFACES--&gt;
        &lt;typeAlias alias="IUnitOfWorkFactory" type="Abc.Project.Domain.Repository.UnitOfWork.IUnitOfWorkFactory, Abc.Project.Domain.Repository"/&gt;
  
        &lt;!-- CONCRETE CLASSES--&gt;
  
        &lt;!-- SERVICE APPLICATION--&gt;
        &lt;typeAlias alias="ApplicationService" type="Abc.Project.Application.Services.Global.ApplicationService, Abc.Project.Application.Services"/&gt;
  
        &lt;!--DATA ACCESS--&gt;
        &lt;typeAlias alias="UnitOfWorkFactory" type="Abc.Project.DataAccess.NHibernate.UnitOfWork.UnitOfWorkFactory, Abc.Project.DataAccess.NHibernate"/&gt;
  
      &lt;/typeAliases&gt;
      &lt;containers&gt;
        &lt;container&gt;
          &lt;!--&lt;extension type="Interception" /&gt;--&gt;
          &lt;types&gt;
  
            &lt;type type="IApplicationService" mapTo="ApplicationService"&gt;
              &lt;lifetime type="singlecall"/&gt;
            &lt;/type&gt;
            &lt;type type="IUnitOfWorkFactory" mapTo="UnitOfWorkFactory"&gt;
              &lt;lifetime type="singleton"/&gt;
            &lt;/type&gt;
  
          &lt;/types&gt;
        &lt;/container&gt;
      &lt;/containers&gt;
    &lt;/unity&gt;
  
    &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="Abc.Project.WcfService.WcfServiceAspNetAjaxBehavior"&gt;
            &lt;enableWebScript/&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="metadataAndDebug"&gt;
            &lt;serviceMetadata httpGetEnabled="true" httpGetUrl=""/&gt;
            &lt;serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/&gt;
      &lt;services&gt;
        &lt;service name="Abc.Project.WcfService.WcfService" behaviorConfiguration="metadataAndDebug"&gt;
          &lt;endpoint address="" behaviorConfiguration="Abc.Project.WcfService.WcfServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="Abc.Project.WcfService.WcfService"/&gt;
        &lt;/service&gt;
      &lt;/services&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>How can I solve this?
  English is not my native language; please excuse typing errors.</p>