我正在使用.net 4.5 Web API項目(Project#1),並且出現一個奇怪的錯誤。原本一切都建在一個項目中。我發現我想將業務邏輯(項目BLL)分解成一個單獨的類庫,以便它可以在其他項目中重用。我已經完成了將它拆開的過程,並發現它可以在項目#2中使用。當我嘗試運行Project#1時,出現了一個奇怪的問題,當我嘗試調用Project BLL中的函數時,在Application_Start中發生TypeLoadException。我在Project#2中調用了這個相同的函數,沒有任何問題。這個問題似乎只在項目#1中,在分裂之前運行良好。我得到確切的錯誤信息是:TypeLoadExeception從Application_Start調用類庫
Could not load type 'Project.BLL.Mappers.v1.AutoMapperConfiguration' from assembly 'Project.BLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
在項目#1我能夠使用Intelesense和F12(轉到定義)看到,這兩個項目似乎正確連接起來。有什麼想法嗎?
更新: 這是整個堆棧跟蹤。它不打在Global.asax.cs中斷點所以我不能真正到了內部異常:
[TypeLoadException: Could not load type 'Project.BLL.Mappers.v1.AutoMapperConfiguration' from assembly 'Project.BLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.]
Project.BLL.WebApiApplication.Application_Start() in d:\Solutions\Project_1\Global.asax.cs:58
[HttpException (0x80004005): Could not load type 'Project.BLL.Mappers.v1.AutoMapperConfiguration' from assembly 'Project.BLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12864365
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Could not load type 'Project.BLL.Mappers.v1.AutoMapperConfiguration' from assembly 'Project.BLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881108
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722297
可能有更多關於* why的信息,運行時無法在InnerException中加載類型。 –
這些都是一樣的.NET版本嗎? –
亞當 - 我已經添加了上面的堆棧跟蹤信息 – bechbd