我已经在IIS中托管了一个asp.net webapi项目。对该项目的api调用会引发错误,如下所述。将项目托管到另一个Web服务器的IIS中时,相同的webapi调用可以正常工作。
[RoutePrefix("api/datacc")]
public class DataAccessController : ApiController
{
[HttpGet]
[Route("")]
public int HeartBeat()
{
return 1;
}
}
错误
*[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) +0
System.Reflection.RuntimeModule.GetTypes() +9
System.Reflection.Assembly.GetTypes() +61
FluentNHibernate.AssemblyTypeSource.GetTypes() in c:\work\coding\fluentNhibernate\src\FluentNHibernate\AssemblyTypeSource.cs:27
FluentNHibernate.PersistenceModel.AddMappingsFromSource(ITypeSource source) in c:\work\coding\fluentNhibernate\src\FluentNHibernate\PersistenceModel.cs:80
FluentNHibernate.Cfg.FluentMappingsContainer.Apply(PersistenceModel model) in c:\work\coding\fluentNhibernate\src\FluentNHibernate\Cfg\FluentMappingsContainer.cs:122
FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg) in c:\work\coding\fluentNhibernate\src\FluentNHibernate\Cfg\MappingConfiguration.cs:80
FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in c:\work\coding\fluentNhibernate\src\FluentNHibernate\Cfg\FluentConfiguration.cs:249
[FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
]
ProjectName2.Data.UnitOfWork..ctor(String databaseConnectionString) in C:\agent\_work\5\s\.....\ProjectName\UnitOfWork.cs:169
ProjectName.WebApiConfig.Register(HttpConfiguration config) in C:\agent\_work\5\s\.....\ProjectName\App_Start\WebApiConfig.cs:66
System.Web.Http.GlobalConfiguration.Configure(Action`1 configurationCallback) +27
ProjectName.WebApiApplication.Application_Start() in C:\agent\_work\5\s\....\ProjectName\Global.asax.cs:18
[HttpException (0x80004005): An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +10093921
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +218
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10075124
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254*
答案 0 :(得分:0)
我敢打赌,从您遇到问题的新IIS服务器连接到数据库时会出现问题。这来自NHibernate,所以这是数据库的问题。但是,如果它在一台服务器上工作,则可能配置正确。确认您可以直接从新的IIS服务器访问数据库。